海报质量出版图表

发布于 2025-02-13 17:18:59 字数 782 浏览 0 评论 0原文

好的,我有以下数据,我需要与条形图一起绘制条形图。

import pandas as pd
import matplotlib.pyplot as plt

data1 = {'Mode': ['foot', 'bike', 'bus', 'car', 'metro'],
         'Segments': [4443, 306, 1070, 5947, 322]}

data2 = {'Mode': ['foot', 'bike', 'bus', 'car', 'metro'],
         'Segments': [2224, 132, 817, 2078, 179]}

因此,我希望将这些dfs的绘图条形图绘制到我在方法论部分下的海报(部分左栏)的一部分,以便可读。

预期图表格式:

我在Google表中创建了上图,但是将其插入海报模板时不可读取(在Google幻灯片中可用)。

如果相关,我的海报模板具有以下字体尺寸:

Title = 85 points
Author = 56 points
Headings = 78 points
sub-headings = 36 points
body text = 30 points

OK, I have the following data, that I needed to plot bar chart with.

import pandas as pd
import matplotlib.pyplot as plt

data1 = {'Mode': ['foot', 'bike', 'bus', 'car', 'metro'],
         'Segments': [4443, 306, 1070, 5947, 322]}

data2 = {'Mode': ['foot', 'bike', 'bus', 'car', 'metro'],
         'Segments': [2224, 132, 817, 2078, 179]}

So I want plot bar chart of these dfs to a section of my poster (left column of section) under methodology section,such that it is readable.

Expected chart format:
enter image description here

I created the above chart in Google sheet, but it is not readable when inserted to poster template (available in Google slides).

If relevant, my poster template has the following font sizes:

Title = 85 points
Author = 56 points
Headings = 78 points
sub-headings = 36 points
body text = 30 points

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

双手揣兜 2025-02-20 17:18:59

您可以使用plt.rcparams来指定所需的样式。首先,定义这些图应为的实际尺寸。例如,如果您的海报有1M的宽度,两列,并且您并排放置两个条形图,则其宽度约为9x8英寸。然后,您可以将标签和刻度设置为您想要的尺寸,例如,文本为30点。在代码开头执行此操作,然后进行图。例如:

plt.rcParams['font.size'] = 30
plt.rcParams['figure.figsize'] = (9, 8)
plt.rcParams['xtick.major.width'] = 4
plt.rcParams['ytick.major.width'] = 4
plt.rcParams['xtick.major.size'] = 10
plt.rcParams['ytick.major.size'] = 10
plt.rcParams['figure.dpi'] = 600
spines_linewidth = 3

fig, ax = plt.subplots()
ax.bar(data1['Mode'], data1['Segments'])

xpositions = [0, 1, 2, 3, 4]
shift = 150
for i, segment in enumerate(data1['Segments']):
    ax.text(xpositions[i], segment + shift, segment, ha='center')
    
for spine in ax.spines:
    ax.spines[spine].set_linewidth(spines_linewidth)
    
ax.set_ylim(top=6500)

结果:

”在此处输入图像描述”

现在是您造型颜色/等的问题,以更好地匹配其余的您的海报,然后导出您的数字并将其移至Google幻灯片。

You can specify the styles you want with plt.rcParams. First, define the actual size these graphs should be. For example, if your poster has 1m of width, two columns, and you're placing two barplots side by side, then their widths would be about 9x8 inches. Then, you can set the labels and ticks and so on to the size you want, for example, 30 points for text. Do this in the beginning of your code, then do your plots. For example:

plt.rcParams['font.size'] = 30
plt.rcParams['figure.figsize'] = (9, 8)
plt.rcParams['xtick.major.width'] = 4
plt.rcParams['ytick.major.width'] = 4
plt.rcParams['xtick.major.size'] = 10
plt.rcParams['ytick.major.size'] = 10
plt.rcParams['figure.dpi'] = 600
spines_linewidth = 3

fig, ax = plt.subplots()
ax.bar(data1['Mode'], data1['Segments'])

xpositions = [0, 1, 2, 3, 4]
shift = 150
for i, segment in enumerate(data1['Segments']):
    ax.text(xpositions[i], segment + shift, segment, ha='center')
    
for spine in ax.spines:
    ax.spines[spine].set_linewidth(spines_linewidth)
    
ax.set_ylim(top=6500)

Resulted in this:

enter image description here

Now it's a matter of you styling the colors/etc to better match the rest of your poster, then exporting your figures and moving them to Google Slides.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文