plt.figure(r'Normalized Mean velocity field - U/U_HB') plt.tricontourf(tsc.x, tsc.y, tsc.triangles, tsc.fields['U'].Umag(), levels, cmap='gray') #palette['SPECTRAL']['DIV']) plt.plot([-0.5, 0.5, 0.5, -.5, -.5], [0.5, 0.5, 1.5, 1.5, 0.5], 'g', lw=1) plt.axis('scaled') plt.axis([-2, 6, 0, 3]) plt.xlabel(r'$x/H$') plt.ylabel(r'$z/H$') plotenv.colorbar(ticks, orientation='h', format='%g') plotenv.cleanupFigure(despine=False) if saveFig: plt.savefig('surface_UField.png') # ---------------------------------------------------------- Temperature # levels = np.linspace(299,305,21)-273 #np.hstack((, 0.99,1.01, np.arange(1.1,2.1,0.1))) # ticks = np.linspace(299,305,11)-273 #np.hstack((np.arange(0,1,0.2), 1.0, np.arange(1.2,2.1,0.2))) #levels = np.linspace(303,306,21)-273 #np.hstack((, 0.99,1.01, np.arange(1.1,2.1,0.1))) #ticks = np.linspace(303,306,11)-273 #np.hstack((np.arange(0,1,0.2), 1.0, np.arange(1.2,2.1,0.2))) levels = np.linspace(28, 31, 21) ticks = np.linspace(28, 31, 11) plt.figure(r'Temperature - T') plt.tricontourf(tsc.x, tsc.y, tsc.triangles,
""" Basic: Simple plotting ====================== """ import matplotlib.pyplot as plt import numpy as np # Plotting wrapper import plotenv as pen palette = pen.initialize() colors = palette['mpl'] # Generate data x = np.linspace(-1, 1, 100) y = np.cos(3 * x) * np.sin(2 * x) # Plot - CMB DIV cmap fig, ax = pen.figure(figsize=(8, 4)) ax.plot(x, y, c=colors['orange'], label='orange') ax.set(xlabel='$x$', ylabel='$y$') # Custom plot wrapper pen.cleanupFigure() ax.legend()
# ticks = np.linspace(0,2,12) #np.hstack((np.arange(0,1,0.2), 1.0, np.arange(1.2,2.1,0.2))) levels = np.hstack([0, np.arange(20)*0.1 + 0.05, 2.0]) #np.hstack((, 0.99,1.01, np.arange(1.1,2.1,0.1))) ticks = np.arange(9)*0.25 #np.hstack((np.arange(0,1,0.2), 1.0, np.arange(1.2,2.1,0.2))) plt.figure(r'Normalized Mean velocity field - U/U_HB') plt.tricontourf(tsc.x, tsc.y, tsc.triangles,tsc.fields['U'].Umag()/1.0, levels,cmap=palette['SPECTRAL']['DIV']) plt.plot([-0.5,0.5,0.5,-.5,-.5],[0.5,0.5,1.5,1.5,0.5],'g',lw=1) plt.axis('scaled') plt.axis([-2,6,0,3]) plt.xlabel(r'$x/H$') plt.ylabel(r'$y/H$') plotenv.colorbar(ticks,orientation='h',format='%g') plotenv.cleanupFigure(despine=False) if saveFig: plt.savefig('surface_UField.png') # ---------------------------------------------------------- Temperature # levels = np.linspace(299,305,21)-273 #np.hstack((, 0.99,1.01, np.arange(1.1,2.1,0.1))) # ticks = np.linspace(299,305,11)-273 #np.hstack((np.arange(0,1,0.2), 1.0, np.arange(1.2,2.1,0.2))) #levels = np.linspace(303,306,21)-273 #np.hstack((, 0.99,1.01, np.arange(1.1,2.1,0.1))) #ticks = np.linspace(303,306,11)-273 #np.hstack((np.arange(0,1,0.2), 1.0, np.arange(1.2,2.1,0.2))) #levels = np.linspace(26,32,21) #ticks = np.linspace(26,32,11) levels = np.hstack((-3,np.arange(20)*0.3-2.85,3)) ticks = np.hstack((-3,np.arange(9)[1::2]*0.3-2.85,0,2.85-np.arange(9)[1::2][::-1]*0.3,3)) #ticks = np.linspace(-3,3,11) plt.figure(r'Temperature - T')
import matplotlib.pyplot as plt import numpy as np # Plotting wrapper import plotenv # Setting up plotting environment palette = plotenv.set(plotType='line', numColors=9, interactive=True) # returns palette # Generate data x = np.linspace(-1, 1, 100) y = [np.cos(i * x / 10) * np.sin(i * x / 10) for i in range(9)] # labels labels = [ 'Alizarin', 'Peter river', 'Emerald', 'Sun Flower', 'Wisteria', 'Midnight blue', 'Asbestos', 'Green sea', 'Pumpkin' ] # Plot plt.figure() for i in range(9): plt.plot(x, y[i], c=palette[i], label=labels[i]) plt.xlabel(r'$x$') plt.ylabel(r'$y$') plt.legend() # Custom plot wrapper plotenv.cleanupFigure()
====================== """ import numpy as np # Plotting wrapper import plotenv as pen # Setting up plotting environment palette = pen.initialize() cmap = palette['CMB']['DIV'] # Generate data xi = np.linspace(-1, 1, 100) X, Y = np.meshgrid(xi, xi) Z = np.cos(3 * X) * np.sin(2 * Y) # Levels and ticks levels = np.linspace(xi.min(), xi.max(), 22) ticks = levels[::2] # Plot - SPECTRAL DIV cmap fig, ax = pen.figure(figsize=(8, 5)) im = ax.contourf(X, Y, Z, cmap=cmap, levels=levels) ax.axis('scaled') ax.set(xlabel='$x$ (unit)', ylabel='$y$ (unit)') pen.colorbar(im, ax, drawEdges=True) # Cleanup pen.cleanupFigure(despine=False)