数学函数或一组数据的图形表示。有不同种类的图,例如线图,条形图或散点图。
我想用Python绘制一些钻井数据。由于它们是在海上不同层次上进行钻孔的,因此我想对齐所有三个子图都与主曲线Y轴对齐。我准备了一个素描,我想像一下结尾。
我现在遇到的问题是,我无法生成不同大小的子图箱,这些子图是相同的比例,并且它们与y轴零不符。
在python matplotlib中,绘制多杆图时,如果值是nan,则可以跳过栏,以免出现?
丢失了每组7个条的某些数据,值为0或NAN。这也在丢失的数据中造成了差距。
mtcars%>% ggplot( aes(as.factor(carb),fill=as.factor(am)))+ geom_bar(aes( y=..count../tapply(..count.., ..fill.. ,sum)[..fill..]), position="fill")+ facet_wrap(~as.factor(vs))+ theme(legend.position = "bottom")
如何从matplotlib中的分类网格点绘制多边形? (阶段形式生成)
I有一个数据框,其中包含1681个均匀分布的2D网格点。每个数据点都有其X和Y坐标,一个代表其类别(或阶段)的标签以及该类别的颜色。 ...
以来 /USR/lib/pymodules/python2.7/matplotlib/legend.py:610:userWarning:传说不支持[ 以来 /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),)) this this甚至是用这样的琐碎脚本发生的: 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() 我发现了错误指向我在诊断错误源方面毫无用处的链接。 您应该添加逗号: plot1, = plt.plot(a,b) plot2, = plt.plot(a,c) 您需要逗号的原因是因为plt.plot()返回了线对象的元组,无论实际上是从命令中创建了多少。如果没有逗号,“ plot1”和“ plot2”是元素而不是线对象,则使后来呼叫plt.legend()失败。 逗号隐含地解开结果,以便将元组“ plot1”和“ plot2”自动成为元组中的第一个对象,即您实际想要的线对象。 http://matplotlib.sourceforge.net/users/legend_guide.html#adjusting-the-prod-the-prode-the-cord--erord-of-legend-items, line,=情节(x,sin(x))逗号代表什么? 使用“标签”关键字,就像这样: plt.plot(x, y, label='x vs. y') 然后添加传奇人物: plt.legend() 传说将保留厚度,颜色等的线属性。 使用handles又名Proxy artists import matplotlib.lines as mlines import matplotlib.pyplot as plt # defining legend style and data blue_line = mlines.Line2D([], [], color='blue', label='My Label') reds_line = mlines.Line2D([], [], color='red', label='My Othes') plt.legend(handles=[blue_line, reds_line]) plt.show() I在直方图图上也有类似的问题。这并不是OP所要求的,而是将我的发现贴在“传奇不起作用”的未来访客: 该代码不起作用: fig, ax = plt.subplots(figsize=(10, 6)) sns.histplot(data=df_stats, x="score", hue="sys", weights=df_stats[sname], bins=10, kde=False, multiple="dodge") ax.legend(title="Systems", labels=[labels[k] for k in sys_names]) 更改以下代码后,它开始按预期工作 fig, _ = plt.subplots(figsize=(10, 6)) ax = sns.histplot(data=df_stats, x="score", hue="sys", weights=df_stats[sname], bins=10, kde=False, multiple="dodge") ax.legend(title="Systems", labels=[labels[k] for k in sys_names]) 传说的问题是什么?注意ax对象初始化的位置!PS,副驾驶/Chatgpt也无法解决我的错误,并使我感到沮丧。 使用绘制图时使用标签,然后只能使用图例。 X轴名称和Y轴名称与传奇名称不同。
如何用ggplot2? 我试图用两个传说获得一个情节,一个在底部,另一个在情节的右侧。 图书馆(整洁) DF
library(tidyverse) df <- tibble(names = mtcars %>% rownames(), mtcars) #plot 1 p1 <- df %>% filter(names == "Duster 360" | names == "Valiant") %>% ggplot(aes(x = as.factor(cyl), y = mpg, color = names)) + geom_point() + geom_hline(aes(yintercept = 20, linetype = "a")) + theme(legend.position = "bottom") p1 <- tibble(names = mtcars %>
如何将Yyaxis中的曲线复制到MATLAB图中的其他曲线?
我在图中绘制了两条曲线。渗透性和阻抗。 然后尝试将相同类型曲线复制并粘贴以比较1:1。 但是右侧的曲线右边是剩下的yyaxis,我不...
我可以让它适用于散点图,但是在试图调用线条时,我以某种方式会遇到错误。
使用复选框时,它添加或删除了y_variables列表中的变量并更新绘图。它有效,但我会收到以下错误:
我想创建一个带有R底座的Barplot。我现在的问题是,我想将y轴间隔从2更改为1。 (目前我有步骤0,2,4,6,8,10,12;我想要0,1,2,3,4,5,6,7,8 ...