标签: figure

在Matplotlib中,参数在fig.add_subplot(111)中意味着什么?

有时我遇到这样的代码:

import matplotlib.pyplot as plt
x = [1, 2, 3, 4, 5]
y = [1, 4, 9, 16, 25]
fig = plt.figure()
fig.add_subplot(111)
plt.scatter(x, y)
plt.show()
Run Code Online (Sandbox Code Playgroud)

哪个产生:

由包含的代码生成的示例图

我一直在疯狂阅读文档,但我无法找到解释111.有时我看到了212.

这个论点fig.add_subplot()意味着什么?

python matplotlib figure

439
推荐指数
7
解决办法
26万
查看次数

Matplotlib不同大小的子图

我需要在图中添加两个子图.一个子图需要大约是第二个(相同高度)的三倍.我使用GridSpeccolspan论证完成了这个,但我想这样做,figure所以我可以保存为PDF.我可以使用figsize构造函数中的参数调整第一个数字,但是如何更改第二个图的大小?

python plot matplotlib figure

206
推荐指数
6
解决办法
24万
查看次数

Matplotlib(pyplot)savefig输出空白图像

我正在尝试使用matplotlib保存我的图表; 但是,图像保存为空白.

这是我的代码:

plt.subplot(121)
plt.imshow(dataStack, cmap=mpl.cm.bone)

plt.subplot(122)
y = copy.deepcopy(tumorStack)
y = np.ma.masked_where(y == 0, y)

plt.imshow(dataStack, cmap=mpl.cm.bone)
plt.imshow(y, cmap=mpl.cm.jet_r, interpolation='nearest')

if T0 is not None:
    plt.subplot(123)
    plt.imshow(T0, cmap=mpl.cm.bone)

    #plt.subplot(124)
    #Autozoom

#else:
    #plt.subplot(124)
    #Autozoom

plt.show()
plt.draw()
plt.savefig('tessstttyyy.png', dpi=100)
Run Code Online (Sandbox Code Playgroud)

并且tessstttyyy.png是空白的(也尝试使用.jpg)

python image matplotlib figure

136
推荐指数
4
解决办法
13万
查看次数

使用twiny时,Python Matplotlib图标题与轴标签重叠

我试图使用twiny在同一图表上绘制两个单独的数量,如下所示:

fig = figure()
ax = fig.add_subplot(111)
ax.plot(T, r, 'b-', T, R, 'r-', T, r_geo, 'g-')
ax.set_yscale('log')
ax.annotate('Approx. sea level', xy=(Planet.T_day*1.3,(Planet.R)/1000), xytext=(Planet.T_day*1.3, Planet.R/1000))
ax.annotate('Geostat. orbit', xy=(Planet.T_day*1.3, r_geo[0]), xytext=(Planet.T_day*1.3, r_geo[0]))
ax.set_xlabel('Rotational period (hrs)')
ax.set_ylabel('Orbital radius (km), logarithmic')
ax.set_title('Orbital charts for ' + Planet.N, horizontalalignment='center', verticalalignment='top')


ax2 = ax.twiny()
ax2.plot(v,r,'k-')
ax2.set_xlabel('Linear speed (ms-1)')

show()
Run Code Online (Sandbox Code Playgroud)

并且数据显示得很好,但我遇到的问题是图形标题与辅助x轴上的轴标签重叠,因此它几乎不易读(我想在这里发布图片示例,但我没有足够高的代表).

我想知道是否有一种简单的方法可以直接将标题移动几十个像素,这样图表看起来更漂亮.

python matplotlib title figure

128
推荐指数
6
解决办法
15万
查看次数

我如何告诉Matplotlib创建第二个(新)情节,然后在旧照片上绘图?

我想绘制数据,然后创建一个新的数字和绘制数据2,最后回到原始绘图和绘图data3,有点像这样:

import numpy as np
import matplotlib as plt

x = arange(5)
y = np.exp(5)
plt.figure()
plt.plot(x, y)

z = np.sin(x)
plt.figure()
plt.plot(x, z)

w = np.cos(x)
plt.figure("""first figure""") # Here's the part I need
plt.plot(x, w)
Run Code Online (Sandbox Code Playgroud)

仅供参考我如何告诉matplotlib我已经完成了一个情节?做类似的事情,但并不完全!它不允许我访问原始情节.

python plot matplotlib figure

123
推荐指数
4
解决办法
28万
查看次数

如何使用pandoc在markdown中引用数字?

我目前正在写下markdown的文档,我想从我的文本中引用一个图像.

this is my text, I want a reference to my image1 [here]. blablabla

![image1](img/image1.png)
Run Code Online (Sandbox Code Playgroud)

我想做那个参考,因为在将我的降价转换为pdf之后,图像会放在一页或两页之后,文档没有任何意义.

更新:

我试过瑞安的回答这个职位,我不能让它工作.显然代码:

[image]: image.png "Image Title" 
![Alt text][image] 
A reference to the [image](#image).
Run Code Online (Sandbox Code Playgroud)

应该产生:

\begin{figure}[htbp] 
\centering 
\includegraphics[keepaspectratio,width=\textwidth,height=0.75\textheight]{i mage.png} 
\caption{Alt text} 
\label{image} 
\end{figure} 

A reference to the image (\autoref{image}).
Run Code Online (Sandbox Code Playgroud)

相反,我获得:

\begin{figure}[htbp]
\centering
\includegraphics{image.png}
\caption{Alt text}
\end{figure}

A reference to the \href{\#image}{image}.
Run Code Online (Sandbox Code Playgroud)

我注意到两个问题:

  • \label{image} 没有出现:没有创建引用.
  • (\autoref{image})变为\href{\#image}{image}:未检测到交叉引用.

然后,当我将其转换为pdf时,它显然没有链接到图像.有一个链接,但它没有链接到任何东西.

任何帮助将非常感激!!

markdown latex cross-reference figure pandoc

95
推荐指数
5
解决办法
4万
查看次数

plot.new()出错:图边距太大,散点图

我已经在寻找解决方案的不同问题,我已经尝试了建议,但我没有找到解决方案使其工作.

每次我想运行此代码时,它总是说:

plot.new()出错:数字边距太大

我不知道如何解决它.这是我的代码:

par(mfcol=c(5,3))
hist(RtBio, main="Histograma de Bio Pappel")
boxplot(RtBio, main="Diagrama de Caja de Bio Pappel")
stem(RtBio)
plot(RtBio, main="Gráfica de Dispersión")

hist(RtAlsea, main="Histograma de Alsea")
boxplot(Alsea, main="Diagrama de caja de Alsea")
stem(RtAlsea)
plot(RtTelev, main="Gráfica de distribución de Alsea")

hist(RtTelev, main="Histograma de Televisa")
boxplot(telev, main="Diagrama de Caja de Televisa")
stem(Telev)
plot(Telev, main="Gráfica de dispersión de Televisa")

hist(RtWalmex, main="Histograma de Walmex")
boxplot(RtWalmex, main="Diagrama de caja de Walmex")
stem(RtWalmex)
plot(RtWalmex, main="Gráfica de dispersión de Walmex")

hist(RtIca, main="Histograma de Ica")
boxplot(RtIca, main="Gráfica de …
Run Code Online (Sandbox Code Playgroud)

plot r margins figure

86
推荐指数
6
解决办法
31万
查看次数

如何强制两个数字保持在LaTeX的同一页面?

我有两个想要在页面上显示的图像作为数字.每个人吃的空间都不到可用空间的一半,所以在那个页面上没有太多空间容纳任何其他东西,但我知道这两个数字都有足够的空间.我试图用[ht]和[hb]放置数字,[h]和[ht],但我仍然无法在同一页面上获得这两个图像,而是至少在它们之间有几段.

如何强制这两个数字保持在同一页面上?

layout latex image figure

82
推荐指数
4
解决办法
13万
查看次数

如何使用pylab远程保存数字?

我正试图用命令在远程计算机上生成一个数字pylab.savefig.但我得到了这样的错误:

Unable to access the X Display, is $DISPLAY set properly?
Run Code Online (Sandbox Code Playgroud)

如何正确保存图形?

python matplotlib figure

71
推荐指数
1
解决办法
3万
查看次数

如何在Python matplotlib图中防止数字被改为指数形式

我在Python中使用Matplotlib来绘制简单的xy数据集.这会生成漂亮的图形,但是当我使用图形视图(执行时出现plt.show())在绘制图形的各个部分上"放大"太近时,x轴值从标准数字形式(1050,1060, 1070等)具有指数表示法的科学形式(例如1,1,5,2.0,其中x轴标记为+1.057e3).

我更喜欢我的数字保留轴的简单编号,而不是使用指数形式.有没有办法可以强制Matplotlib这样做?

python graph matplotlib figure

70
推荐指数
5
解决办法
6万
查看次数

标签 统计

figure ×10

matplotlib ×7

python ×7

plot ×3

image ×2

latex ×2

cross-reference ×1

graph ×1

layout ×1

margins ×1

markdown ×1

pandoc ×1

r ×1

title ×1