subplot

matplotlib modify outer x label and keep inner x label

matplotlib modify outer x label and keep inner x label Question: I have a plot with 2 x_labels for two subplots. The inner x label is "Bronx, Brooklyn, Manhanttan, Queens, Staten Island"(or is it call x tick?), the outer x label is "borough": I want to find two different solutions to handle the "borough" labels. …

Total answers: 1

Matplotlib : How to separate the last subplot line and the last subplot column in a figure?

How to separate the last subplot line and the last subplot column in a figure Question: Using matplotlib, I plotted n x n subplots (n=8 in this example): fig, ax = plt.subplots(8,8, figsize=(18,10), sharex=’col’, sharey=’row’) fig.subplots_adjust(hspace=0, wspace=0) And I would like to separate the last line and the last column to obtain something like this …

Total answers: 2

Rotate axis labels

Rotate axis labels Question: I have a plot that looks like this (this is the famous Wine dataset): As you can see, the x-axis labels overlap and thus I need to be rotated. NB! I am not interested in rotating the x-ticks (as explained here), but the label text, i.e. alcohol, malic_acid, etc. The logic …

Total answers: 2

How to deal with the colorbar axis space in matplotlib subplots

How to deal with the colorbar axis space in matplotlib subplots Question: I am plotting seven different parameters over four seasons, as shown in below image. but on last column (Post-Monsoon) sub_plots axis compromised with colorbar axis, that is really awkward!! import matplotlib.pyplot as plt import cartopy import cartopy.crs as ccrs from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, …

Total answers: 3

Too much space between subplots with gridspec

Too much space between subplots with gridspec Question: I am trying to make a figure with a grid of 12 plots on the left and one larger plot on the right. The problem is that matplotlib adds far too much space between the small subplots. How can I get rid of this space? import matplotlib.pyplot …

Total answers: 2

How to place a single colorbar for two gridspec subplots

How to place a single colorbar for two gridspec subplots Question: I am trying to plot 6 plots in the form of a grid using gridspec. I want one color bar placed at the bottom between the 2nd and 3rd columns. My code is as follows, but it generates 6 colorbars. How can I change …

Total answers: 1

How can I set the y axis limit?

How can I set the y axis limit? Question: I am comparing the training accuracies of two different neural networks. How can I set the scales so that they are comparable. (like setting both y axis to 1 for both so that the graphs are comparable) The code I used is below: def NeuralNetwork(X_train, Y_train, …

Total answers: 2

Changing the GridSpec properties after generating the subplots

Changing the GridSpec properties after generating the subplots Question: Suppose something comes up in my plot that mandates that I change the height ratio between two subplots that I’ve generated within my plot. I’ve tried changing GridSpec‘s height ratio to no avail. import matplotlib.pyplot as plt from matplotlib.gridspec import GridSpec fig = plt.figure() gs = …

Total answers: 1

How to create a twin axes with gridspec

How to create a twin axes with gridspec Question: I am using two GridSpec objects to generate the following plot: import numpy as np import matplotlib.pyplot as plt from matplotlib.figure import figaspect plt.rcParams.update({‘figure.figsize’ : (10,10)}) plt.rcParams.update({‘font.size’ : 18}) plt.rcParams.update({‘mathtext.fontset’: ‘stix’}) plt.rcParams.update({‘font.family’: ‘STIXGeneral’}) My code: n_rows = 3 n_cols = 3 gs_right = plt.GridSpec(n_rows,n_cols, left=0.25,right=0.95,hspace=0) gs_left …

Total answers: 1

How do I fix plt.subplots to bring the plots closer together?

How do I fix plt.subplots to bring the plots closer together? Question: I am plotting 27 maps, or 9 rows and 3 columns. I am using plt.subplots to plot them, but I am struggling to bring the plots closer together? I tried both: plt.tight_layout() fig.tight_layout() But I keep getting this error anytime I add that …

Total answers: 2