我有一个生成不同类型图表的 Web 服务。图表是使用编程方式生成的,System.Windows.Forms.DataVisualization.Charting并将它们保存为 .png 文件。但无论我做什么,图表的尺寸都是 300x300 像素。
在互联网上,我找到了许多更改图表大小的解决方案,但它们仅适用于将图表放入 WinForm 然后保存到文件的情况。
如果我的应用程序中没有 WinForms,如何更改图表的大小?
这是我在代码中所做的一个虚拟示例
int[] yVal = { 1, 1, 1, 1, 1, 1, 1 };
string[] xName = { "a", "b", "b", "b", "b", "b", "b" };
System.Windows.Forms.DataVisualization.Charting.Chart Chart1 = new Chart();
Chart1.Titles.Add("Title");
Chart1.Series.Add(new Series());
Chart1.Series[0].XValueType = ChartValueType.String;
Chart1.Series[0].YValueType = ChartValueType.Int32;
Chart1.Series[0].Points.DataBindXY(xName, yVal);
Chart1.Palette = ChartColorPalette.EarthTones;
Chart1.Legends.Add(new Legend());
Chart1.Legends[0].Enabled = false;
ChartArea chartArea = new ChartArea();
chartArea.AxisX.Title = "X";
chartArea.AxisY.Title = "Y";
Chart1.ChartAreas.Add(chartArea);
Chart1.SaveImage("chart.png", ChartImageFormat.Png);
Run Code Online (Sandbox Code Playgroud) 我正在使用 matlibplot 进行数据可视化。我的绘图总共有 6502 个数据值并且工作正常,但这些值很接近且密集。
例如,我的 y 轴值范围在 3 到 10 之间,我需要如此清楚地获得它们之间的每个点。即,像 9.2 和 9.8 这样的值至少要用 1=0.5 的比例来清楚地区分。即所有像 3,3.5,4,4.5...10,10.5 这样的值都可以在输出图中看到
有人可以解释我如何做到这一点。我厌倦了使用最大值和最小值的设置范围。但它没有用。我将限制设置为 3.5 到 10.5,但在图中,坐标轴以 1=1 的比例显示,值从 4 到 10。请帮我解决这个问题
提前致谢
到目前为止,这是我的代码
import matplotlib.pyplot as plt
import numpy as np
import plotly.plotly as py
c, ec = np.random.rand(2, len(votes), 10)
fig, ax = plt.subplots()
plt.ylim(3.5, 10.5)
plt.grid(True)
# where votes range from 10-1000000 and rank range from 3.5 to 10
matplotlib.pyplot.scatter(votes,rank, c=c, edgecolor=ec)
plot_url = py.plot_mpl(fig, filename='scatter-plot')
matplotlib.pyplot.show()
Run Code Online (Sandbox Code Playgroud)
我的情节就在这里

我试图让一个情节看起来像 R 中的彭博终端的情节,我发现了以下 Mathematica 帖子:
https://mathematica.stackexchange.com/questions/48185/make-plot-look-like-bloomberg-terminal
我的问题是,这可以在 RI 中使用 ggplot2 完成吗?
在 ggplot2 中, geom_point 默认在当前绘图上绘图。例如,在调用 geom_boxplot 后调用 geom_point 会导致绘制在箱线图上的点:
ggplot(iris, aes(x = "All", y = Sepal.Length)) +
geom_boxplot() +
geom_point(aes(color=Species), position = "jitter")
Run Code Online (Sandbox Code Playgroud)
有没有办法将点分别绘制到侧面,而不是在箱线图上?
在我的特殊情况下,我想这样做是因为点模糊了绘图(即使是透明的等),这里的示例数据集不是问题。
我想更改 Vega-Lite 条形图中条形的默认蓝色。我该怎么做?我在下面发布了 json 规范:
{
"data": {
"values": [
{"a":"A", "b":28}, {"a":"B", "b":55}, {"a":"C", "b":43},
{"a":"D", "b":91}, {"a":"E", "b":81}, {"a":"F", "b":53},
{"a":"G", "b":19}, {"a":"H", "b":87}, {"a":"I", "b":52}
]
},
"mark": "bar",
"encoding": {
"x": {bin:false, "type": "ordinal","field": "a"},
"y": {"type": "quantitative","field": "b"}
}
}
Run Code Online (Sandbox Code Playgroud)
提前致谢。
我需要为我的图形添加一些背景线,例如x=0和y=0和对角线的粗线。每次更改图形的配色方案/“样式”时,我都必须手动更改这些线条的颜色。
有没有办法检索当前图形样式的颜色?
如何访问 D3 回调中的当前选择?
group.selectAll('.text')
.data(data)
.enter()
.append('text')
.text((d) => d)
.attr('class', 'tick')
.attr('y', (d) => {
// console.log(this) <-- this gives me window :( but I want the current selection or node: <text>
return d
})
Run Code Online (Sandbox Code Playgroud)
我可以d3.select('.tick')在回调中做一个,因为到那时我已经添加了一个类并且可以通过 d3.select 获取节点,但是如果我没有添加这个类呢?
我正在尝试使用变量深度、距离和温度创建深度剖面图。收集的数据来自 9 个已知距离的不同点(距离 5m,9 个站点,9 组不同的数据)。温度读数是根据探测器直接下降的这 9 个站点,每 2 秒读取一次温度读数。9 个站点中每个站点的最大深度也取自船上。
所以我的数据是:
是否可以创建与此类似的深度剖面?(显然在这张图中没有更大的分辨率)
我已经尝试过使用 ggplot2 和 raster 但我似乎无法弄清楚如何做到这一点。我遇到的问题之一是如何让 ggplot2 区分站点 1 的 5m 深度温度读数和站点 5 的 5m 温度读数,因为它们具有相同的深度值。
即使您可以指导我使用另一个程序来创建这样的图表,那也很棒
我正在使用 matplotlib 绘制纬度经度坐标中的变量。问题是此图像不能包含轴或边框。我已经能够删除轴,但我的图像周围的白色填充必须完全删除(请参阅下面代码中的示例图像:http : //imgur.com/a/W0vy9)。
我尝试了 Google 搜索中的几种方法,包括这些 StackOverflow 方法:
如何删除 matplotlib 子图中的填充/边框(已解决)
但在去除空白方面没有任何作用。如果您有任何建议(即使是放弃 matplotlib 并尝试使用另一个绘图库),我将不胜感激!
这是我正在使用的代码的基本形式,它显示了这种行为:
import numpy as np
import matplotlib
from mpl_toolkits.basemap import Basemap
from scipy import stats
lat = np.random.randint(-60.5, high=60.5, size=257087)
lon = np.random.randint(-179.95, high=180, size=257087)
maxnsz = np.random.randint(12, 60, size=257087)
percRange = np.arange(100,40,-1)
percStr=percRange.astype(str)
val_percentile=np.percentile(maxnsz, percRange, interpolation='nearest')
#Rank all values
all_percentiles=stats.rankdata(maxnsz)/len(maxnsz)
#Figure setup
fig = matplotlib.pyplot.figure(frameon=False, dpi=600)
#Basemap code can go here
x=lon
y=lat
cmap = matplotlib.cm.get_cmap('cool') …Run Code Online (Sandbox Code Playgroud) 我想提供以下数据
x <- factor(c(1,2,3,4,5))
x
[1] 1 2 3 4 5
Levels: 1 2 3 4 5
value <- c(10,5,7,4,12)
value
[1] 10 5 7 4 12
y <- data.frame(x, value)
y
x value
1 1 10
2 2 5
3 3 7
4 4 4
5 5 12
Run Code Online (Sandbox Code Playgroud)
我想将上述信息转换为以下图形表示
上面描述的图形类型是什么?我检查了点图,但只是垂直堆叠.
ggplot2 ×4
matplotlib ×3
python ×3
r ×3
charts ×2
d3.js ×2
bar-chart ×1
bloomberg ×1
c# ×1
graphics ×1
javascript ×1
plot ×1
resize ×1
scatter-plot ×1
vega ×1
vega-lite ×1
web-services ×1