How to plot this this graph?

一曲冷凌霜 提交于 2019-12-02 08:25:24

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!

Set your data up like this, then after you've selected the range for a bar chart, you'll need to swap the X and Y axis:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!