Python 3.x 调整轴长度

Python 3.x 调整轴长度,python-3.x,matplotlib,Python 3.x,Matplotlib,晚上好,, 我正在用以下代码在此图上绘制我的DF: from matplotlib import cm from mpl_toolkits.mplot3d import Axes3D from matplotlib.colors import LightSource import matplotlib.pyplot as plt import matplotlib.ticker as ticker from matplotlib.ticker import MultipleLocator #f

晚上好,, 我正在用以下代码在此图上绘制我的DF:

from matplotlib import cm
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.colors import LightSource
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
from matplotlib.ticker import MultipleLocator

#fig(finestra) creation and subplot(threedee) creation#
finestra = plt.figure(figsize = (10,20))
threedee = finestra.add_subplot(1,1,1, projection = '3d')

#meshgrid#
x,y = np.meshgrid(df_giornaliero_p.columns, df_giornaliero_p.index)
z = df_giornaliero_p.values

#projection, grid's step setting to 1, axis labels, colorbar e show#
grafico = threedee.plot_surface(x, y, z, rstride=1, cstride=1, linewidth=0, cmap=cm.coolwarm, antialiased=0)

threedee.xaxis.set_major_locator(MultipleLocator(1))
threedee.yaxis.set_major_locator(MultipleLocator(1))
threedee.zaxis.set_major_locator(MultipleLocator(1))

threedee.set_xlabel('COLONNE')
threedee.set_ylabel('ESTRAZIONI')
threedee.set_zlabel('VALORI')

finestra.colorbar(grafico, shrink=1, aspect=90)

plt.show()
结果:


现在,正如大家所看到的,我的Y和Z刻度值重叠,我想知道是否有办法扩展Y和Z轴,以获得一个更宽的图形,并清楚地查看所有数据,这正是我要寻找的

请注意:

-厚度计数必须设置为(x=20,y=288,z=90)

-要存储的是轴长度或每个刻度之间的步数

-我真的不关心图形实际具有的长方体形状

提前谢谢大家。晚上好

你不能通过玩弄
figsize
来做到这一点吗

假设
df_giornaliero_p
设置如下:

df_giornaliero_p=pd.DataFrame(np.random.random((20,20))*100

并且figsize增加了:

finestra = plt.figure(figsize = (20,60))
您还可以在
plt.show()之前调整文本大小:

我明白了

晚上好

你不能通过玩弄
figsize
来做到这一点吗

假设
df_giornaliero_p
设置如下:

df_giornaliero_p=pd.DataFrame(np.random.random((20,20))*100

并且figsize增加了:

finestra = plt.figure(figsize = (20,60))
您还可以在
plt.show()之前调整文本大小:

我明白了


我的第一个想法是在3daxis对象上使用
change\u aspect()
。但这显然没有实现,至少在matplotlib 3.1.3中没有实现。因此,您可以通过更改figuresize来解决这个问题,但这并不是很令人满意。实际上,我已经尝试了
axis.change\u aspect()
并获得了您的错误代码
“Axes3DSubplot”对象没有属性“change\u aspect”。
因此,我只想了解我是在寻找一个不存在的东西还是有办法。抱歉,我输入错误。想到的功能是
set\u aspect
。这会抛出一个
NotImplementedError:目前无法在三维轴上手动设置纵横比
我的第一个想法是在三维轴对象上使用
change\u aspect()
。但这显然没有实现,至少在matplotlib 3.1.3中没有实现。因此,您可以通过更改figuresize来解决这个问题,但这并不是很令人满意。实际上,我已经尝试了
axis.change\u aspect()
并获得了您的错误代码
“Axes3DSubplot”对象没有属性“change\u aspect”。
因此,我只想了解我是在寻找一个不存在的东西还是有办法。抱歉,我输入错误。想到的功能是
set\u aspect
。这会抛出一个
NotImplementedError:目前无法在3D轴上手动设置纵横比
这只会拉伸绘图,顺便说一下,由于figsize使用2d参数,因此无法在2d屏幕上增加图像深度。无论如何,谢谢你,我想我还是放弃吧。这只会影响画面,顺便说一句,因为figsize使用2d参数,所以在2d屏幕上增加图像深度是不可能的。谢谢你,我想我还是放弃吧。