I’m trying to get my chart started from position 0 using hist()

Asked

Viewed 118 times

0

Using USAGE_PLOT became easy to do but I want to do and learn how to use Hist. the same way it is in the image below where it was used usage_plot(trip_data, 'duration', ['duration < 60'], boundary = 0, bin_width = 5) resultado

But I’m trying a lot of different things and I’m not getting the same result:

plt.figure()

trip_data_ex = trip_data[trip_data['duration'] < 60]

data_plot_ex = trip_data
data_plot_ex['count'] = 1

data_plot_ex = trip_data_ex.groupby('duration', as_index=False).count()
x_data = trip_data_ex['duration'].unique()
min_value = data_plot_ex['duration'].min()
bins = [i*5 + min_value -1 for i in range(13)]

plt.hist(data_plot_ex['count'], bins, width=4.9)

plt.show()

Mais próximo que cheguei.

Any idea how to get to the first image ? Grateful for the help.

  • The numbers are completely different (8000 vs 800) ==> different images...

1 answer

0

I found this answer who uses the pylab.hist as the parameter histtype="stepfilled" . If this doesn’t work, you can try using asymmetrical bars, increasing the size of problematic bars.

If none of these things work, like you have bars together and starting from scratch, you can easily modify your date and plot a area or patch. The date needs a little attention to make the points, as some techniques use slightly different inputs. But the time shouldn’t be too different from making the bars asymmetrical.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.