Trouble With Stacked Bar Graph Without Pooling
I have a clear idea of what I would like to plot, but I am not sure where to start using matplotlib/seaborn. I have ~999 unequal lines of 0s, 1s, and 2. Here is an example of one l
Solution 1:
With 1000 rows I guess you're better off if you display your data as an image using imshow
rather than a bar chart. Put your data (0
, 1
or 2
) in an array of 999 rows and as many columns as the longest sequence, initilize that array with -1
.
Example with just 100 rows for better readability:
import matplotlib.pyplot as plt
import numpy as np
# generate some sample data
n, m = 10, 20
a = np.random.randint(0, 3, (n,m))
s = np.random.randint(int(m/2), m, n)
for i in range(n):
a[i,s[i]:] = -1
# show them as image
cmap = plt.matplotlib.colors.ListedColormap(['w', 'r', 'lime', 'b'])
plt.imshow(a, cmap=cmap)
You can then adjust axis ticks and labels as needed.
Post a Comment for "Trouble With Stacked Bar Graph Without Pooling"