我希望有人能指出我正确的方向。python datavis 领域现在已经变得巨大,并且有太多的选择,我有点不知道实现这一目标的最佳方法是什么。
我有一个 xarray 数据集(但它很容易是一个 Pandas 数据框或一个 numpy 数组列表)。
我有 3 列,A、B 和 C。它们包含 40 个数据点。
我想绘制 A vs B + scale*C 的散点图,其中比例是从交互式滑块确定的。
更高级的版本会有一个下拉列表,您可以在其中选择一组不同的 3 列,但稍后我会担心这一点。
对所有这些的警告是,我希望它在线并且可以交互以供其他人使用。
似乎有很多选择:
任何想法或建议将不胜感激。
可以通过执行以下操作在 2D 图表上实现虚线网格:
#include <QApplication>
#include <QtCharts>
using namespace QtCharts;
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
auto chart = new QChart;
chart->addSeries(new QLineSeries);
chart->createDefaultAxes();
chart->axes(Qt::Horizontal)[0]->setGridLinePen(Qt::DashLine);
chart->legend()->hide();
QChartView view(chart);
view.show();
view.resize(400,300);
return a.exec();
}
Run Code Online (Sandbox Code Playgroud)
并且可以通过以下方式实现 3D 图表:
#include "mainwindow.h"
#include <Q3DBars>
using namespace QtDataVisualization;
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
auto chart = new Q3DBars;
setCentralWidget(QWidget::createWindowContainer(chart));
}
MainWindow::~MainWindow() {}
Run Code Online (Sandbox Code Playgroud)
如何在 3D 图表上设置虚线网格线?
我想在 Matlab 中绘制一个带有阴影区域的函数,表明它的不确定性(例如,置信区间)。这可以通过使用fill创建色块的功能来实现。例如
x = linspace(0, 2*pi, 100);
f = cos(x);
fUp = cos(x) + 1;
fLow = cos(x) - 1;
x2 = [x, fliplr(x)];
plot(x, f, 'k')
hold on
fill(x2, [f, fliplr(fUp)], 0.7 * ones(1, 3), 'linestyle', 'none', 'facealpha', 0.4);
fill(x2, [fLow, fliplr(f)], 0.7 * ones(1, 3), 'linestyle', 'none', 'facealpha', 0.4);
Run Code Online (Sandbox Code Playgroud)
这会在函数fLow和之间创建一个灰色阴影区域fUp,f中间用黑色实线表示,如下图所示。
我现在希望当我们接近置信区间的下限(或上限)时,阴影区域会降低其颜色。特别是,当接近它的边界时,我希望阴影区域变得越来越亮。有没有办法做到这一点?我正在做两个单独的补丁,因为我认为这可能是我的目的所必需的。
我想将渐变(垂直)颜色条添加到我在 Julia 中的专题地图图中,其值来自变量values。下面的地图是人口密度区划。
任何关于如何添加渐变图例栏的建议?
我的代码(包括下载 en 解压打开的数据 shapefile):
using DataFrames
using Plots
using Shapefile
using ZipFile
# make directory downloads
downloads = joinpath(pwd(), "downloads")
if ~ispath(downloads)
mkpath(downloads)
end
# make directory shapefiles
shapefiles = joinpath(pwd(), "shapefiles")
if ~ispath(shapefiles)
mkpath(shapefiles)
end
# download shapefiles
url = "https://www.cbs.nl/-/media/cbs/dossiers/nederland-regionaal/wijk-en-buurtstatistieken/wijkbuurtkaart_2020_v1.zip"
name_zipfile = split(url, "/")[end]
path_zipfile = joinpath(pwd(), "downloads", name_zipfile)
if ~isfile(path_zipfile)
download(url, path_zipfile)
end
# extract shapefiles
path_shapefile = joinpath(pwd(), "shapefiles", "gemeente_2020_v1.shp")
if ~isfile(path_shapefile)
r = ZipFile.Reader(path_zipfile)
for file in r.files
open(joinpath(pwd(), …Run Code Online (Sandbox Code Playgroud) 我有这个用Vega-lite制作的条形图(代码和图片如下)。
但我想自定义图例标签,以便不是 videoGame 而是Video Game ,而不是tv而是TV 。有办法做到这一点吗?
lineChart = vegalite ({
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"width": 560,
"height": 200,
"data": {"values": chartData},
"mark": {"type": "bar"},
"encoding": {
"x": {"field": "year_reference", "type": "temporal", "axis": {"title": "Year", "grid": true}},
"y": {"field": "reference_count_total", "type": "quantitative", "axis": {"title": "References", "grid": true}},
"color": {
"field": "title_type",
"scale": {
"domain": [
"tv",
"movie",
"video",
"videoGame"
],
"range": [
"#9e9ac8",
"#74c476",
"#a6761d",
"#6baed6"
]
},
"legend": true,
"title": "Reference Type"
},
}
Run Code Online (Sandbox Code Playgroud)
})
我正在尝试vis.js使用 React 来渲染网络可视化。为此,我一直遵循 James Tharpe 的指南: https: //www.jamestharpe.com/react-visjs/。但是,出现了以下错误......
请在这个仓库中查看我的代码:
https://github.com/murilobellatini/try-vis-network
你们能帮我让这段代码工作吗?
谢谢!
我正在使用 R。使用教程,我能够创建一个统计模型并为一些输出生成可视化图:
#load libraries
library(survival)
library(dplyr)
library(ranger)
library(data.table)
library(ggplot2)
#use the built in "lung" data set
#remove missing values (dataset is called "a")
a <- na.omit(lung)
#create id variable
a$ID <- seq_along(a[,1])
#create test set with only the first 3 rows
new <- a[1:3,]
#create a training set by removing first three rows
a <- a[-c(1:3),]
#fit survival model (random survival forest)
r_fit <- ranger(Surv(time,status) ~ age + sex + ph.ecog + ph.karno + pat.karno + meal.cal + …Run Code Online (Sandbox Code Playgroud) 这不是这个的重复。
添加<extra></extra>确保trace#已从图表中删除。但是有没有办法让我把它设为默认设置?
我正在创建一个自定义的 plotly 主题,并希望它成为默认设置,但它包含在trace类中而不是包含在类中layout。此外,将它添加到调用中的每个跟踪plotly.go调用是重复的。
要重新创建图形 -
import pandas as pd
import plotly.graph_objects as go
from plotly.subplots import make_subplots
world_df = pd.DataFrame({'date': {494: '2021-05-09',
495: '2021-05-10',
496: '2021-05-11',
497: '2021-05-12',
498: '2021-05-13',
499: '2021-05-14',
500: '2021-05-15',
501: '2021-05-16',
502: '2021-05-17',
503: '2021-05-18'},
'total_deaths': {494: 3293029.0,
495: 3303796.0,
496: 3317412.0,
497: 3331346.0,
498: 3344481.0,
499: 3357610.0,
500: 3369259.0,
501: 3379349.0,
502: 3389992.0,
503: 3404338.0}})
#Comment out line below for exact …Run Code Online (Sandbox Code Playgroud) 我正在使用 Open3D 来可视化我正在处理的 3D 点云。为此,我使用open3d.visualization.Visualizer。效果很好。现在我希望将此窗口嵌入到更大的 GUI 中,在其中我将显示两个 Visualizer 窗口以及它们下面的一些文本标签。基本上,这将是一个简单的设计,其中两个 Visualizer 对象彼此相邻,文本显示在它们下方。来自同一库的 GUI 模块位于此处。我似乎无法从文档中弄清楚这是否可能?是否有其他框架可以让我做到这一点?
有没有办法使用rpart.plot库来绘制不属于的对象rpart(用于制作决策树)?
例如,以下是正在运行的经典rpart库rpart.plot:
#load libraries
library(rpart)
library(rpart.plot)
#load data
data(iris)
#fit rpart model (i.e. decision tree)
r = rpart(Species ~., data=iris)
#plot model
rpart.plot(r)
Run Code Online (Sandbox Code Playgroud)
问题:我正在研究一个多类分类问题(如上面的示例 - 我只是用著名的“iris 数据集”说明了这一点),其中“rpart”运行时间太长(我等了 10 个小时,“rpart”代码仍然没有运行)。
然而,我在 R 中发现了另一个名为“c50”的库,它能够立即创建类似的模型:
#load library
library(C50)
#run same model
tree_mod <- C5.0(x = iris[, -5], y = iris$Species, rules = TRUE)
#view model
summary(tree_mod)
plot(tree_mod)
Run Code Online (Sandbox Code Playgroud)
问题:是否可以将“rpart.plot”库与“C50”库中的对象一起使用?
例如:
#my attempt
rpart.plot(tree_mod)
Error in rpart.plot(tree_mod) : Not an rpart object
Run Code Online (Sandbox Code Playgroud)
我的想法: 可以使用“C50”库提取不同的规则:
summary(tree_mod) …Run Code Online (Sandbox Code Playgroud) python ×3
plot ×2
plotly ×2
r ×2
3d ×1
bokeh ×1
c++ ×1
charts ×1
choropleth ×1
dataframe ×1
ggplot2 ×1
javascript ×1
julia ×1
matlab ×1
matplotlib ×1
open3d ×1
opengl ×1
point-clouds ×1
python-3.x ×1
qt5 ×1
reactjs ×1
rpart ×1
tree ×1
vega-lite ×1
vis.js ×1