如何绘制此图? [英] How to plot this this graph?

查看:98
本文介绍了如何绘制此图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,数据可视化专家!



我正在尝试在python中绘制此图形手绘示例。





但是,似乎与正常情节相比,情节要复杂得多。



如果可视化专家可以帮助您对此进行绘制,那将是非常不错的。在手绘图中,我将所有线条保留为红色,但是它们可以使用不同的颜色。



感谢您的回复:)

解决方案

没有数据,我无法帮助绘制它,但是您可以按照以下示例通过Python来解决它:




认为正在寻找。这可能不是一个完美的解决方案,但我认为它展示了制作此类图的方法:)。如果此解决方案解决了您的问题,希望您可以单击我的帖子旁边的复选标记以接受它作为您正在寻找的答案!


Hi Data Visulization Experts!

I'm trying to plot this graph hand-drawn example here in python.

However, it seems it will be much trickier to plot as compared to normal plots.

It would be really nice if a visualisation expert can help in plotting this. In the hand-drawn figure I kept all the lines red, however, they can be in different colours.

Thank you for your responses :)

解决方案

Without the data I cannot assist in plotting it, but you can solve it via Python by following the examples at:

https://matplotlib.org/gallery/units/bar_demo2.html?highlight=bar

^ You can perhaps have each bar chart on a separate subplot?

If your input is multiple sets of data you can look into maybe a multiple dataset histogram at

https://matplotlib.org/gallery/statistics/histogram_multihist.html?highlight=hist

^ If you want to have the first column of all categories next to each other, then the second bar, etc..

Perhaps you would prefer just a standard histogram though:

https://matplotlib.org/gallery/statistics/histogram_features.html?highlight=hist

It really depends on what you are trying to emphasize from your data

@EDIT

Here is a Python program to plot your information! You can easily adjust the width (I commented out a way to set the width to cover the empty gaps, but its slightly off) and to plot a line I would use width = 0.01

import matplotlib.pyplot as plt
import numpy as np

data = {0: [4, 8, 6],
        1: [2, 4, 3, 6],
        2: [3, 6],
        3: [10, 3, 8, 6, 10, 12]}

fig, ax = plt.subplots(tight_layout=True)

for key, values in data.items():
    ind = np.arange(key, key + 1, 1/len(data[key]))
    width = 0.1 # 1/len(data[key])
    ax.bar(ind + width/len(values), data[key], width, align='center', label="Category {}".format(key + 1))

ax.xaxis.set_ticks([])
ax.set_xticklabels(' ')
ax.legend()
ax.set_ylabel('Some vertical label')
plt.title('My plot for Stack Overflow')
plt.show()

This outputs: Which I think is what you're looking for. This may not be a perfect solution, but I think it showcases the methodology used to make such plots :). If this solution solved your problem, I would appreciate if you could click the check mark by my post to accept it as the answer you were looking for!

这篇关于如何绘制此图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆