0

I would like to make a gridplot in Seaborn (or Matplotlib) in Python as shown in the image attached below. The code for the individual plots is as follows:

import os, sys
import pandas as pd
from math import *
import numpy as np
import matplotlib.pyplot as pt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import matplotlib.gridspec as gridspec
import seaborn as sns
from Data_handling import * #own code

u_arr, v_arr = load_arrays(full_path, profile_name)
            N, n = u_arr.shape[1], u_arr.shape[0]
            t_max = 0.5*(n-1)

            xs = np.linspace(0, L-(L/N), N)
            ys = np.linspace(0, t_max, n)
            X, Y = np.meshgrid(xs, ys)

            pt.xlabel('x', fontsize = 18)
            pt.ylabel('Time', fontsize = 18)
            pt.contour(X, Y, u_arr.real, 20, cmap='RdGy')
            pt.imshow(u_arr.real, extent=[xs[0], xs[-1], ys[0], ys[-1]],
                      vmin=0, vmax=1, origin='lower', cmap='RdGy', aspect='auto')
            pt.colorbar()
            pt.savefig(
                os.path.join(full_path,
                             os.path.join(
                                 os.path.join('ST_Figures', 'u_profile'),
            'i={0}_k={1}_F={2}_dt={3}_tmax={4}.png'.format(
                i, k, F,
                str(dt).replace('.', ','), str(t_max).replace('.', ',')))),
                       dpi=500)
            pt.close()

but I would edit to have a 4x4 graph plot with the axis labels as shown here: Desired Multiplot (created in InkScape)

That's to say:

  • one colorbar
  • labels on the bottow row and column on the LHS
  • yticks on all plots, but xticks on only the bottom row
  • decent spacing
Jelmes
  • 33
  • 6
  • Please do the following: 1) Fix indentation as Python maintains syntax rules on tabs/spaces and 2) set up a [reproducible example](https://stackoverflow.com/q/20109391/1422451) (as we do not have any of your data). – Parfait Aug 06 '18 at 18:03
  • Such an [MCVE] should allow us to copy/paste your posted code in our empty Python environments to fully compile and run to reproduce your undesired results. – Parfait Aug 06 '18 at 18:04
  • That would require a lot of code, and files,which I am sure will not be able to be uploaded. – Jelmes Aug 06 '18 at 18:05
  • There's no errors though. It's a matter of creating a gridplot according to my specification set out in the example and shown. – Jelmes Aug 06 '18 at 18:06
  • Then the idea is to set up a much a smaller sample (see first link above) and the emphasis of *minimum* in MCVE. No errors? Then, that is why I mention to reproduce *undesired* results. – Parfait Aug 06 '18 at 18:06
  • I have given an example and set out the specification. – Jelmes Aug 06 '18 at 18:07
  • What is *full_path, profile_name* in `load_arrays()`? – Parfait Aug 06 '18 at 18:07
  • The working directory and filename to be found in subfolder. – Jelmes Aug 06 '18 at 18:21
  • See https://stackoverflow.com/questions/13784201/matplotlib-2-subplots-1-colorbar – ImportanceOfBeingErnest Aug 07 '18 at 13:00

0 Answers0