How to make matplotlib show all x coordinates?
Use plt.xticks(x). See the documentation. Note that using only the input values for ticks will usually be confusing to a viewer. It makes more sense to use evenly spaced ticks.
Use plt.xticks(x). See the documentation. Note that using only the input values for ticks will usually be confusing to a viewer. It makes more sense to use evenly spaced ticks.
The issue here is that the number of ticks -set automatically – isn’t the same as the number of points in your plot. To resolve this, set the number of ticks: ax1.set_xticks(np.arange(len(x))) Before the ax1.set_xticklabels(x) call.
You have the right method. Maybe you are not applying the set_xticks to the correct axes. An example: import matplotlib.pyplot as plt import numpy as np ncols = 5 nrows = 3 # create the plots fig = plt.figure() axes = [ fig.add_subplot(nrows, ncols, r * ncols + c) for r in range(0, nrows) for … Read more
You can set the fontsize directly in the call to set_xticklabels and set_yticklabels (as noted in previous answers). This will only affect one Axes at a time. ax.set_xticklabels(x_ticks, rotation=0, fontsize=8) ax.set_yticklabels(y_ticks, rotation=0, fontsize=8) Note this method should only be used if you are fixing the positions of the ticks first (e.g. using ax.set_xticks). If you … Read more
Ok, finally got it working. The trick was to use plt.setp to manually rotate the tick labels. Using fig.autofmt_xdate() did not work as it does some unexpected things when you have multiple subplots in your figure. Here’s the working code with its output: for i, d in enumerate([360, 30, 7, 1]): ax = axes.flatten()[i] earlycut … Read more
You don’t need the label_wrap function. Instead use the str_wrap function from the stringr package. You do not provide your df data frame, so I create a simple data frame, one that contains your labels. Then, apply the str_wrap function to the labels. library(ggplot2) library(stringr) df = data.frame(x = c(“label”, “long label”, “very, very long … Read more