My data recording system has center values [0,10,20,...350], and the data is assumed to collected evenly from the center points. Therefore, I want to plot histogram binned in this way: [-5,5],[5,15],[15,25] ... [345, 355].
The problem is that, the data are stored in [0, 360], which would make the inital and end sector just half of the data.
Simply put, when I want to plot the data for [-5,5], the actual data ploted would just have half the size , since [-5,5] is split into [0,5] and [355,360]. You can look at the 0
, 355
bin at the pic below.
bins=np.arange(-5, 360 + 10, 10)
df['dir'].hist(bins=bins, alpha=0.5, figsize=(15, 3))
My questions are:
half size
problem? -50
, is there way to get rid of it? 1: if you don't want the beautiful polar plot suggested by roadrunner, and instead want to keep your linear bar chart, you should assign any values > 355 to the 0 bin, eg,
wrapped = np.array(df['dir'])
wrapped[wrapped > 355] = 0
plt.hist(wrapped, bins=np.arange(0,370,10), align='left')
(align='left' plots your bins from, eg, -5..5, 5..15, etc given data values ranging from 0..355)
2: now get rid of that unwanted space on the left with:
plt.axis('tight')
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.