我试图使标题不言自明,但这里 - 数据优先:
dtf <- structure(list(variable = structure(c(1L, 1L, 2L, 2L, 3L, 3L,
4L, 4L, 5L, 5L), .Label = c("vma", "vla", "ia", "fma", "fla"), class = "factor"),
ustanova = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L), .Label = c("srednja škola", "fakultet"), class = "factor"),
`(all)` = c(42.9542857142857, 38.7803203661327, 37.8996138996139,
33.7672811059908, 29.591439688716, 26.1890660592255, 27.9557692307692,
23.9426605504587, 33.2200772200772, 26.9493087557604)), .Names = c("variable",
"ustanova", "(all)"), row.names = c(NA, 10L), class = c("cast_df",
"data.frame"), idvars = c("variable", "ustanova"), rdimnames = list(
structure(list(variable …Run Code Online (Sandbox Code Playgroud) 我试图绘制一条平滑的曲线R.我有以下简单的玩具数据:
> x
[1] 1 2 3 4 5 6 7 8 9 10
> y
[1] 2 4 6 8 7 12 14 16 18 20
Run Code Online (Sandbox Code Playgroud)
现在,当我使用标准命令绘制它时,它看起来很崎岖和前卫,当然:
> plot(x,y, type='l', lwd=2, col='red')
Run Code Online (Sandbox Code Playgroud)
如何使曲线平滑,以便使用估计值对3条边进行舍入?我知道有很多方法可以拟合平滑曲线,但我不确定哪种方法最适合这种类型的曲线以及如何编写它R.
自从升级matplotlib以来,每次尝试创建图例时都会出现以下错误:
/usr/lib/pymodules/python2.7/matplotlib/legend.py:610: UserWarning: Legend does not support [<matplotlib.lines.Line2D object at 0x3a30810>]
Use proxy artist instead.
http://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist
warnings.warn("Legend does not support %s\nUse proxy artist instead.\n\nhttp://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist\n" % (str(orig_handle),))
/usr/lib/pymodules/python2.7/matplotlib/legend.py:610: UserWarning: Legend does not support [<matplotlib.lines.Line2D object at 0x3a30990>]
Use proxy artist instead.
http://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist
warnings.warn("Legend does not support %s\nUse proxy artist instead.\n\nhttp://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist\n" % (str(orig_handle),))
Run Code Online (Sandbox Code Playgroud)
这甚至发生在这样一个简单的脚本:
import matplotlib.pyplot as plt
a = [1,2,3]
b = [4,5,6]
c = [7,8,9]
plot1 = plt.plot(a,b)
plot2 = plt.plot(a,c)
plt.legend([plot1,plot2],["plot 1", "plot 2"])
plt.show()
Run Code Online (Sandbox Code Playgroud)
我发现错误指向我的链接在诊断错误源方面毫无用处.
有没有办法matplotlib直接从dict使用数据绘制条形图?
我的字典看起来像这样:
D = {u'Label1':26, u'Label2': 17, u'Label3':30}
Run Code Online (Sandbox Code Playgroud)
我在期待
fig = plt.figure(figsize=(5.5,3),dpi=300)
ax = fig.add_subplot(111)
bar = ax.bar(D,range(1,len(D)+1,1),0.5)
Run Code Online (Sandbox Code Playgroud)
工作,但它没有.
这是错误:
>>> ax.bar(D,range(1,len(D)+1,1),0.5)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/matplotlib/axes.py", line 4904, in bar
self.add_patch(r)
File "/usr/local/lib/python2.7/site-packages/matplotlib/axes.py", line 1570, in add_patch
self._update_patch_limits(p)
File "/usr/local/lib/python2.7/site-packages/matplotlib/axes.py", line 1588, in _update_patch_limits
xys = patch.get_patch_transform().transform(vertices)
File "/usr/local/lib/python2.7/site-packages/matplotlib/patches.py", line 580, in get_patch_transform
self._update_patch_transform()
File "/usr/local/lib/python2.7/site-packages/matplotlib/patches.py", line 576, in _update_patch_transform
bbox = transforms.Bbox.from_bounds(x, y, width, height)
File "/usr/local/lib/python2.7/site-packages/matplotlib/transforms.py", line …Run Code Online (Sandbox Code Playgroud) 我已经用函数创建了一个MATLAB绘图plot().如何更改生成的绘图图形的窗口标题?
我正在研究的MATLAB m文件:
hold on
x = [0; 0.2; 0.4; 0.6; 0.8; 1; 1.2; 1.4; 1.6; 1.8; 2; 2.2; 2.4; 2.6; 2.8; 3; 3.2; 3.4; 3.6; 3.8; 4; 4.2; 4.4; 4.6; 4.8; 5; 5.2; 5.4; 5.6; 5.8; 6; 6.2; 6.4; 6.6; 6.8; 7; 7.2; 7.4; 7.6; 7.8; 8; 8.2; 8.4; 8.6; 8.8; 9; 9.2; 9.4; 9.6; 9.8; 10; 10.2; 10.4; 10.6; 10.8; 11; 11.2; 11.4; 11.6; 11.8; 12; 12.2; 12.4; 12.6; 12.8; 13; 13.2; 13.4; 13.6; …Run Code Online (Sandbox Code Playgroud) 我想用R覆盖同一设备上的2个密度图.我该怎么做?我搜索了网络,但我没有找到任何明显的解决方案(我对R来说很新).
我的想法是从文本文件(列)中读取数据然后使用
plot(density(MyData$Column1))
plot(density(MyData$Column2), add=T)
Run Code Online (Sandbox Code Playgroud)
这种精神......
提前致谢
你如何绘制熊猫系列图中的垂直线(vlines)?我正在使用Pandas绘制滚动方式等,并希望用垂直线标记重要位置.是否可以使用vlines或类似的东西来实现这一目标?如果是这样,有人可以提供一个例子吗?在这种情况下,x轴是日期时间.
我目前有一个nx3矩阵阵列.我想将三列绘制为三个轴.我怎样才能做到这一点?
我用google搜索,人们建议使用Matlab,但我真的很难理解它.我还需要它是散点图.
有人可以教我吗?
在ggplot2,可以轻松地将图形保存到R对象中.
p = ggplot(...) + geom_point() # does not display the graph
p # displays the graph
Run Code Online (Sandbox Code Playgroud)
标准函数plot将图形作为void函数生成并返回NULL.
p = plot(1:10) # displays the graph
p # NULL
Run Code Online (Sandbox Code Playgroud)
是否可以保存plot在对象中创建的图形?
plot ×10
r ×5
matplotlib ×4
python ×4
3d ×1
bar-chart ×1
density-plot ×1
ggplot2 ×1
matlab ×1
pandas ×1
scatter-plot ×1
title ×1