Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing right edge from pyplot histogram

I refer to this example from the Matplotlib site. To the right of the blue "Empirical" curve, there is a vertical blue line, which is the right edge of the rightmost bar.

How can I remove this vertical blue line, without changing the x-axis limits?

like image 568
construed Avatar asked Oct 14 '17 02:10

construed


People also ask

How do I get rid of top and right border in Matplotlib?

To hide the border (aka "spine"): ax. set_frame_on(False) or ax. spines['top']. set_visible(False)

How do I get rid of Xticks in Matplotlib?

To remove the ticks on the x-axis, tick_params() method accepts an attribute named bottom, and we can set its value to False and pass it as a parameter inside the tick_params() function.

How do you space out a histogram in Python?

The space between bars can be added by using rwidth parameter inside the “plt. hist()” function. This value specifies the width of the bar with respect to its default width and the value of rwidth cannot be greater than 1.


1 Answers

This is default behavior. You need to delete the last point.

n, bins, patches = ax.hist(x, n_bins, normed=1, histtype='step',
                           cumulative=True, label='Empirical')

patches[0].set_xy(patches[0].get_xy()[:-1])

The rest are the same.

enter image description here

like image 151
sheldonzy Avatar answered Sep 28 '22 08:09

sheldonzy