简体   繁体   中英

Plotting bar chart matplotlib.pyplot python

I have these very close values to plot using bar chart:

[0.786418528, 0.836312033, 0.796715391, 0.834506989, 0.834181085, 0.792882691, 0.787157068]

But they appear to be very closed projected on y axis. 在此处输入图像描述

How to make them look more discriminated likes this one from excel? 在此处输入图像描述

If you know from before the rough range of your data, you can just set the ylim:

plt.ylim([y_min, y_max])

A smart way of doing this would be to automatically infer the boundaries of your data from the vector you have (assuming it's called y):

y_min = min(y)
y_max = max(y)
offset = (y_max-y_min)*0.3 # To give us some leeway
plt.ylim([y_min-offset, y_max+offset])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM