I want to create a graph similar to this. Is this possible using matplotlib / seaborn. If so, what resources can I use in order to learn how to style matplotlib / seaborn graphs and how can I get the two graphs to line up like this.
The value of Y-axis in a seaborn heatmap is reversed when home icon or H button is pushed.
In Seaborn, we will plot multiple graphs in a single window in two ways. First with the help of Facetgrid() function and other by implicit with the help of matplotlib. data: Tidy dataframe where each column is a variable and each row is an observation.
Seaborn provides an API on top of Matplotlib that offers sane choices for plot style and color defaults, defines simple high-level functions for common statistical plot types, and integrates with the functionality provided by Pandas DataFrame s.
Use a common x-axis and convert one of the datasets to contain negative values.
y = ['{} to {} years'.format(i, i+4) for i in range(0, 90, 4)]
d_1 = np.random.randint(0, 150, 23)
d_2 = -1 * d_1
Then plot:
fig, ax = plt.subplots()
ax.bar(y, d_1)
ax.bar(y, d_2)
# Formatting x labels
plt.xticks(rotation=90)
plt.tight_layout()
# Use absolute value for y-ticks
ticks = ax.get_yticks()
ax.set_yticklabels([int(abs(tick)) for tick in ticks])
plt.show()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With