小编Sos*_*hty的帖子

以百万为单位设置 y 轴

我对这个情节有问题:

[![在此处输入图像描述][1]][1]

y 轴以单位为单位,但我需要它们以百万为单位:

[![在此处输入图像描述][2]][2]

你知道实现这一目标的方法吗?提前致谢。

python axis matplotlib pandas

4
推荐指数
2
解决办法
6565
查看次数

在子图中写入文本

我正在研究这个情节:

在此处输入图片说明

我需要在第一个图中的红线和黑线之间写一些东西,我尝试过,ax1.text()但它显示了两个图之间的文本,而不是第一个图内的文本。我怎样才能做到这一点?

情节是这样设定的:

fig, (ax1,ax2) = plt.subplots(nrows=2, ncols=1, figsize = (12,7), tight_layout = True)
Run Code Online (Sandbox Code Playgroud)

预先感谢您的帮助!

python charts matplotlib

4
推荐指数
1
解决办法
7062
查看次数

匹配两个seaborn图的图例颜色

我有这三个子图,我需要在顶部匹配下方的两个子图的图例中设置大陆的颜色,即欧洲 = 蓝色,亚洲 = 红色,等等。有没有办法做到这一点?我正在使用 Python、seaborn 和 Matplotlib。这是我的代码和结果图:

  fig = plt.figure(figsize=(20,10))


ax1 = plt.subplot(2, 1, 1)
diseases.plot(kind="barh", ax = ax1, width = 0.9, cmap = 'Set1_r')
ax1.set_xticks(np.arange(0,251,25))
ax1.set_ylabel('Countries', fontsize = 15)
ax1.legend(fontsize = 12)

ax2 = plt.subplot(2, 2, 3)
sns.barplot(x = smok_fem.female_smokers, y = smok_fem.index , hue='continent', data = smok_fem, ax = ax2,
            dodge = False, palette = 'tab10')
ax2.set_xlabel('Female Smokers', fontsize = 14)
ax2.set_ylabel('Countries', fontsize = 14)
ax2.legend(fontsize = 14, markerscale = 2, facecolor = 'w')

ax3 = plt.subplot(2, …
Run Code Online (Sandbox Code Playgroud)

python matlab matplotlib pandas seaborn

2
推荐指数
1
解决办法
5694
查看次数

标签 统计

matplotlib ×3

python ×3

pandas ×2

axis ×1

charts ×1

matlab ×1

seaborn ×1