Pandas series plot()中figsize的像素密度/DPI是多少?

2024-10-04 01:33:05 发布

您现在位置:Python中文网/ 问答频道 /正文

对于Pandas系列(pandas.core.series.Series),有一种方便的plot()方法(documentation)来制作,例如条形图。在

{cd2width}值为

figsize : a tuple (width, height) in inches

但是,我找不到任何关于每英寸像素密度/DPI/PPI是多少的文档。似乎也没有任何方法来说明它应该是什么。根据输出图像的大小,我猜它是相当低的(例如,72 dpi),但我想知道它是什么,所以当我教这个方法时,我可以为输出提供一个合理的解释。下面是一个示例用法:

species_counts = surveys.groupby('species_id')['record_id'].count()
type(species_counts) # `pandas.core.series.Series`
species_counts.plot(figsize = (9, 6), kind = 'bar')

我知道这个方法基于matplotlib,但是不幸的是,Pandas系列上的方法没有采用dpi参数(结果是AttributeError: Unknown property dpi)。在


Tags: 方法coreidpandasplotdocumentationseriesspecies
1条回答
网友
1楼 · 发布于 2024-10-04 01:33:05

您可以使用底层的matplotlib命令来指定dpi。在

import matplotlib.pyplot as plt
import pandas as pd
%matplotlib inline

fig = plt.figure(dpi=1000)
species_counts = surveys.groupby('species_id')['record_id'].count()
species_counts.plot(figsize = (9, 6), kind = 'bar')

fig.get_dpi()  # 1000

或者,如果您只想知道默认的dpi是什么:

^{pr2}$

我不认为有一个规范的答案,我很确定确切的答案将取决于您使用的后端,可能还取决于您的硬件。在

相关问题 更多 >