Skip to main content

All Questions

116 votes
3 answers
254k views

Turn off axes in subplots

I have the following code: import matplotlib.pyplot as plt import matplotlib.image as mpimg import matplotlib.cm as cm img = mpimg.imread("lena.jpg") fig, axs = plt.subplots(2, 2) axs[0,0]....
47 votes
2 answers
45k views

How to share secondary y-axis between subplots in matplotlib

If you have multiple subplots containing a secondary y-axis (created using twinx), how can you share these secondary y-axes between the subplots? I want them to scale equally in an automatic way (so ...
418 votes
7 answers
599k views

Matplotlib different size subplots

I need to add two subplots to a figure. One subplot needs to be about three times as wide as the second (same height). I accomplished this using GridSpec and the colspan argument but I would like to ...
0 votes
1 answer
42 views

Matplotlib figure with 2 animation subplots: how to update both

I'm trying to vizualize simulation results with a figure containing 2 subplots using matplotlib pyplot. Both should contain animation: one uses netgraph library (it's a graph with nodes showing flows ...
0 votes
1 answer
96 views

Aligning matplotlib subplots one with stacked bar plot and another with line plot using matplotlib in Python [duplicate]

I have 2 dataframes as follows: df1.to_dict() results in {'Peak Demand PES': {2023: 124126.91, 2025: 154803.41, 2030: 231494.66, 2040: 483217.66000000003, 2050: 1004207.86}, 'Peak Demand TES':...
0 votes
2 answers
42 views

Plot with 8 subplots where 4x4 with horizontal space

I am trying to make a plot where I just want some distance between the first and second set of plots. Basically when you plot below, you can see the y-axis values off ax5 and ax7 there that is where I ...
64 votes
2 answers
46k views

How to change the current axis instance (i.e., gca()) in matplotlib

I use a trick to draw a colorbar whose height matches the master axes. The code is like import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import make_axes_locatable import numpy as np ax = ...
0 votes
1 answer
58 views

How to use the same colour map and scale for two different graphs plotted together (using custom colormap)

I have 3 data sets: height, data1 and data2, where all are different and I want to plot height vs data1 and height vs data2 as a (1,2) subplot using pcolormesh and have them share a colorbar. The ...
592 votes
12 answers
967k views

Improve subplot size/spacing with many subplots

I need to generate a whole bunch of vertically-stacked plots in matplotlib. The result will be saved using savefig and viewed on a webpage, so I don't care how tall the final image is, as long as the ...
0 votes
1 answer
44 views

To plot variable number of plots with variable number of graphs from Pandas grouped by some columns

I've been dealing with Python for the last few months and it still a little bit irritate me :) But hope someone can explain how to plot some subplots from dataframe grouped by 2 columns using ...
0 votes
2 answers
68 views

Align yaxis label spanning two axes with yaxis labels of one axes in subplots

I have a plot with 3 subplots: the top plot is larger than the two subsequent plots. They all share the same x- and y-axis. However, the ylabel is rather long, so the ylabels of the two bottom plots ...
0 votes
1 answer
41 views

How do I create a secondary axis based on on a complex conversion?

I am trying to create a secondary axis for my plot. I can get all of my lines to plot on the graph (y1 to y14) and all y values are in the same units. The conversion to a secondary unit is essentially ...
0 votes
1 answer
42 views

How to superimpose the rotated subplot on the another sublot?

I would like to release such configuration of plots as it presented on the picture: The next parameters have to be variable: Position of subplot origin point Rotation angle of subplot Size of ...
0 votes
1 answer
33 views

Matplotlib - Fix bar chart, using subplots, and inserting labels per each bar

I am creating a bar chart with the following code. I am getting the text I need but the format is incorrect, due is overlap with the titles and part of the first subplot. Could you please tell me how ...
0 votes
1 answer
30 views

Move Span center to click position not showing range when clicking in subplot with shown range

I have created a 2 plot subplot. Selecting the range in both subplots works fine. Clicking into the upper subplot (the zoomed plot) shifts both views fine, but when clicking in the lower (total view) ...

15 30 50 per page
1
2 3 4 5
76