- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
这与 new pythonic style for shared axes square subplots in matplotlib? 有关(或者更确切地说是跟进) .
我想让子图共享一个轴,就像上面链接的问题一样。但是,我也不希望地 block 之间没有空间。这是我的代码的相关部分:
f, (ax1, ax2) = plt.subplots(1, 2, sharex=True, sharey=True)
plt.setp(ax1, aspect=1.0, adjustable='box-forced')
plt.setp(ax2, aspect=1.0, adjustable='box-forced')
# Plot 1
ax1.matshow(pixels1, interpolation="bicubic", cmap="jet")
ax1.set_xlim((0,500))
ax1.set_ylim((0,500))
# Plot 2
ax2.matshow(pixels2, interpolation="bicubic", cmap="jet")
ax2.set_xlim((0,500))
ax2.set_ylim((0,500))
f.subplots_adjust(wspace=0)
结果是这样的:
如果我注释掉这两个 plt.setp() 命令,我会得到一些添加的白色边框:
如何使图形看起来像我的第一个结果,但轴像第二个结果那样接触?
最佳答案
编辑:获得结果的最快方法是@Benjamin Bannier 描述的方法,只需使用
fig.subplots_adjust(wspace=0)
另一种方法是制作一个宽度/高度比等于 2
的图形(因为您有两个图)。仅当您计划在文档中包含图形并且您已经知道最终文档的列宽时,才建议这样做。
您可以在调用 Figure(figsize=(width,height))
时设置宽度和高度,或者作为 plt.subplots()
的参数,在英寸。示例:
fig, axes = plt.subplots(ncols=2, sharex=True, sharey=True,figsize=(8,4))
fig.subplots_adjust(0,0,1,1,0,0)
屏幕截图:
正如@Benjamin Bannier 指出的那样,作为一个缺点,您的利润率是零。然后你可以玩 subplot_adjust()
,但如果你想保持解决方案简单,你必须小心以对称方式留出空间。一个示例可以是 fig.subplots_adjust(.1,.1,.9,.9,0,0)
。
关于python - 绘图 : Shared axes and no space between subplots,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22607444/
是否有我遗漏的原因或某些原因让 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 轴重新排序后
我是一名优秀的程序员,十分优秀!