Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unfilled bar plot in matplotlib

With histograms, there's a simple built-in option histtype='step'. How do I make a bar plot in the same style?

like image 935
Tristan Klassen Avatar asked Aug 09 '12 21:08

Tristan Klassen


People also ask

Is it possible to have a separate color for each category in a bar graph Matplotlib?

there is no color parameter listed where you might be able to set the colors for your bar graph.

How do I change the bar color in Matplotlib?

You can change the color of bars in a barplot using color argument. RGB is a way of making colors. You have to to provide an amount of red, green, blue, and the transparency value to the color argument and it returns a color.


1 Answers

[adding answer after reading the comments] Set the optional keyword to be fill=False for bar plots:

import matplotlib.pyplot as plt

plt.bar(bins[:5], counts[:5], fill=False, width=60)  # <- this is the line

plt.title("Number of nodes with output at timestep")
plt.xlabel("Node count")
plt.ylabel("Timestep (s)")

will give: enter image description here

Or use plt.plot with the keyword ls='steps' :

plt.plot(bins[-100:], counts[-100:], ls='steps')
plt.title("Number of nodes with output at timestep")
plt.xlabel("Node count")
plt.ylabel("Timestep (s)")

enter image description here

like image 94
XValidated Avatar answered Oct 08 '22 00:10

XValidated