Tick frequency
There seem to be multiple issues here:
-
- You are using the = operator while using plt.xticks. You should use a function call instead (but not here; read point 2 first)!
-
- seaborn’s countplot returns an axes-object, not a figure
- you need to use the axes-level approach of changing x-ticks (which is not
plt.xticks()
)
- you need to use the axes-level approach of changing x-ticks (which is not
- seaborn’s countplot returns an axes-object, not a figure
Try this:
for ind, label in enumerate(plot_.get_xticklabels()):
if ind % 10 == 0: # every 10th label is kept
label.set_visible(True)
else:
label.set_visible(False)
Colors
I think the data-setup is not optimal here for this type of plot. Seaborn will interpret each unique value as new category and introduce a new color. If i’m right, the number of colors / and x-ticks equals the number of np.unique(data).
Compare your data to seaborn’s examples (which are all based on data which can be imported to check).
I also think working with seaborn is much easier using pandas dataframes (and not numpy arrays; i often prepare my data in a wrong way and subset-selection needs preprocessing; dataframes offer more). I think most of seaborn’s examples use this data-input.