I can imagine there being two mutually non-exclusive solutions.
Directly alter the size of the font. This can be achieved via calling plt.rcParams.update({'font.size': <font_size>})
, assuming that you have imported matplotlib.pyplot
under the alias plt
, as you have done in the source code provided. You would probably want to set the <font_size>
to be small to prevent overlapping labels, but this would require some experimentation.
Increase the size of the figure. This can be done in a number of ways, but perhaps the simplest method you can implement with minimal edits to your current code would be to use the command plt.rcParams["figure.figsize"] = <fig_size>
where <fig_size>
is a tuple specifying the size of the figure in inches, such as (10, 5)
.
With some trial and error, you should be able to manipulate the size of the font and the figure to produce a plot with improved readability.
Note: The method for altering figure size I introduced above is not the most conventional way to go about this problem. Instead, it is much more common to use matplotlib.pyplot.figure
or similar variants. For more information, I recommend that you check out this thread and the documentation.