- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经开始更多地使用图形和坐标轴,乍一看它似乎非常好:可以独立创建和操作坐标轴对象(通过向其添加绘图或更改比例等),但是我遇到的问题是“图”似乎是唯一可以控制轴对象布局的类。
我想做这样的事情:
def plot_side_by_side(lefts, rights, coupled=True, width_ratios=[2,1]):
import matplotlib.gridspec as gridspec
# lefts and rights are lists of functions that
# take axes objects as keywords, the length of this
# object is the number of subplots we have:
plots = list(zip(lefts, rights))
y_size = len(plots)
# create figure with a number of subplots:
fig = plt.figure(figsize=(10,y_size * 4))
gs = gridspec.GridSpec(y_size,2,width_ratios=width_ratios,height_ratios=[1 for _ in plots])
#get axes on the left
cleft_axes = [plt.subplot(gs[0,0])]
if y_size > 1:
cleft_axes += [plt.subplot(gs[i,0], sharex=cleft_axes[0]) for i in range(1,y_size)]
[plt.setp(ax.get_xticklabels(), visible=False) for ax in cleft_axes[:-1]]
# get axes on the right, if coupled we fix the yaxes
# together, otherwise we don't
if coupled:
yaxes = cleft_axes
else:
yaxes = [None for _ in cleft_axes]
cright_axes = [plt.subplot(gs[0,1], sharey=yaxes[0])]
if y_size > 1:
cright_axes += [plt.subplot(gs[i,1], sharey=yaxes[i], sharex=cright_axes[0]) for i in range(1,y_size)]
[plt.setp(ax.get_xticklabels(), visible=False) for ax in cright_axes[:-1]]
# for each plot in our list, give it an axes object if it is on
# the left or right. Now this function will plot on that axes
for (pl, pr), l, r, name in zip(plots,cleft_axes,cright_axes,names):
pl(ax=l)
pr(ax=r)
return fig
我希望能够创建一个函数,该函数将轴对象作为关键字并在其上放置两个图:
def twoplots(ax=ax):
# make a grid of axes, allow them to be plotted to, etc.
# this is all within the space given me by `ax`.
这可能吗?我将如何去做这样的事情?我知道我可以从传递的轴对象中获取图形,是否可以修改父网格规范而不弄乱所有其他网格规范?
最佳答案
希望我在恢复这么旧的线程时没有犯规。我想就我认为 OP 正在尝试做的事情提供一些额外的背景信息。 (至少我希望这是他正在尝试做的事情,因为我正在尝试做同样的事情。)
假设我有一个由 K 个不同类型的子模型组成的统计模型。我想让子模型自己绘制。大多数时候,在典型情况下,每个子模型都会将自己绘制在一个轴对象上。有时,子模型可能需要多个轴来绘制自身。
例如:假设一个模型是一个时间序列模型,子模型显示趋势、季节性、回归效应、假期效应等。如果季节性效应显示年度季节性,它会像趋势模型一样绘制自己(它的效果与时间)。但是,如果它显示星期几的季节性,则情节与时间的关系将无效,因为线条摆动得太快了。绘制星期一的时间序列,然后是星期二的时间序列等会更有效。为了适应更大的方案,您希望这 7 个图的集群成为“季节性图”。
有了 K 个子模型,您通常可以从fig, ax = plt.submodels(K)
然后将 ax[k]
作为 model.submodel[k].plot(ax[k ])
。问题是当您想在 ax[k]
上绘制上述星期几的季节性影响时该怎么做。
一个答案可能是“不要使用这种机制:使用 GridSpec 或其他东西”。但我认为这就是问题所在。
关于python - Matplotlib 轴 : splitting an axes object into two,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43927863/
是否有我遗漏的原因或某些原因让 Sitecore 为 true 和 Item.Axes.IsDescendantOf() 返回 Item.Axes.IsAncestorOf() ? var test
我最近重构了很多代码,想要一个干净的环境,所以我删除并重新创建了数据库模式,创建了一个新的 venv,并从 pip3 一个一个地安装依赖项,所以我没有'有任何从旧环境遗留下来的多余包。我很快安装了六个
我有一个返回 Figure 对象的外部函数,在这种情况下,每个 Figure 对象都由一个 Axes 对象组成。 我想组成一个由这两个图形组成的新图形(比方说水平连接)。 所以理想情况下,我想说: f
文件说 Axes.text(self, x, y, s, fontdict=None, withdash=deprecated parameter, **kwargs) Add text to the
我对编程和尝试学习 Python 完全陌生。因此,请在询问转储问题的阶段耐心等待。上面的错误是我尝试将 matplotlib.pyplot 导入 Python 时遇到的错误。我不确定如何解决这个问题,
谁能告诉我如何在图表的 x-y 轴上写标签?那些写着“时间(秒)”和“速度(米/秒)”的。 我正在使用 System.Windows.Forms.DataVisualization.Charting.
sitecore 中 item.Axes.GetDescendants() 和 item.Axes.selectitems() 之间的基本/性能区别是什么? 最佳答案 item.Axes.GetDes
我在 Seaborn 中有一个包含 10 个图的 FacetGrid 图表,其中的图略有重叠。我想改变整体图形的大小。当我在下面的代码中使用 g.fig.subplots(figsize=(12,12
有没有一种方法可以检查是否从数据库中检索到字段?我创建了一些从不同位置调用的逻辑。但在某些位置,表缓冲区是使用字段列表选择的。我只想在未检索到该字段的情况下再次执行查询。获取正确记录的查询非常繁重,并
我最近将 django-axes 添加到我的 Django 项目中。它应该用 django-restframework 来解决这个问题。但是,我使用 django-rest-framework-sim
我正在使用 Java2d 开发应用程序。我注意到的奇怪的事情是,原点在左上角,正 x 向右移动,正 y 向下增加。 有没有办法把原点移到左下角? 谢谢。 最佳答案 您将需要进行缩放和翻译。 在您的 p
当前有效matplotlib版本为:3.4.1。 概述 axes()函数功能与subplot()函数极其相似。都是向当前图像(figure)添加一个子图(Axes),并将该子图设为当前子图或者将
XPath 中的 轴( Axes ) 可用于选取相对于当前节点的节点集 XML 范例文档 我们将在接下来的范例中使用下面这份 XML 文档 <?xml version="1.0&
是否可以使用xpath语法进行基于日期的查询?我研究的一切都表明这是不可能的。我正在查询一组日历,只想取回一个月的数据-我可以使用哪些策略来实现这一目标? 2010年8月10日:编辑以获取更多信息 我
所以我有这两个函数来绘制时间序列和直方图。 ax1 = plotTimeSeries(df=dfDelay_Vector) ax2 = plotHistogram( df=dfDelay_Hist)
我有一个 matplotlib Axes对象 self.a在 matplotlib 上定义canvas对象 self.fold_canvas .在它的构建过程中,在某些时候我在地 block 上绘制了
我想知道如何键入提示 matplotlib-subplots 的轴对象的“最佳”方法。 运行 from matplotlib import pyplot as plt f, ax = plt.subp
我们想要在 azure 上部署 AX Dynamics,我们已经创建了 DC/AX AOS/SQL VM 的 . 客户的本地 Pc/AX 客户端如何连接到 azure DC VM? 我可以在不创建虚拟
我想用我选择的颜色图绘制散点图。 我的代码: # Create a scatter plot. scatter = axes[1][1].scatter( fourth.VALP, # First v
我仍在使用 https://github.com/syntagmatic/parallel-coordinates#parallel-coordinates 绘制平行坐标图和 d3.js 轴重新排序后
我是一名优秀的程序员,十分优秀!