I want to get equivalent plot in Julia that i have using Python pcolormesh() function. Here x
and z
are two 270x100
matrices. You can download folder containing that Python script and data at VelocPythJul.tar.gz - Google Drive
density = ax.pcolormesh(x, z, rho[t]*v_p[t], norm=LogNorm(), cmap=colormap)`
Python script is this
# Create the plot
fig = plt.figure(figsize=(20, 20))
ax = plt.subplot(111)
#colormap = custom_colormap('cmap.csv', reverse=False)
colormap = 'jet'
ax.set_xlim((0, x_lim))
ax.set_ylim((0, y_lim))
ax.set_aspect('equal',adjustable='box')
vmin=1.e-8
vmax=1.e-2
density = ax.pcolormesh(x, z, rho[0]*v_p[0], cmap=colormap,
norm=plt.Normalize(vmin=np.log10(vmin), vmax=np.log10(vmax)))#, cmap=colormap, vmin=np.log10(vmin), vmax = np.log10(vmax))
aspect = 40
pad_fraction = 0.5
divider = make_axes_locatable(ax)
width = axes_size.AxesY(ax, aspect=1./aspect)
pad = axes_size.Fraction(pad_fraction, width)
cax = divider.append_axes("right", size=width, pad=pad)
contour = ax.contour(x, z, psi[0], 100, colors='white',linewidth=4,
levels=contour_levels)
cbar = plt.colorbar(density, cax=cax)
cbar.set_label(r"$\mathbf{\rm{log}_{10}(\rho{\rm v_p})}$")
# Save all frames as PNGs
dir = directory
if not os.path.isdir(dir): os.makedirs(dir)
for t in range(N_files):
ax.cla()
ax.set_xlabel(xlabel)
ax.set_ylabel(ylabel)
ax.set_xlim((0, x_lim))
ax.set_ylim((0, y_lim))
ax.minorticks_on()
ax.set_title(title[t],y=1.04)
xticks = ax.xaxis.get_major_ticks()
xticks[0].label1.set_visible(False)
ax.xaxis.set_tick_params(labelsize=50)
ax.yaxis.set_tick_params(labelsize=50)
ax.xaxis.set_tick_params(width=3,length=8)
ax.yaxis.set_tick_params(width=3,length=8)
ax.set_aspect('equal',adjustable='box')
print(psi[t])
density = ax.pcolormesh(x, z, rho[t]*v_p[t], norm=LogNorm(), cmap=colormap)
contour = ax.contour(x, z, psi[t], 100, colors='white',linewidths=2,levels=contour_levels)
contour_alf = ax.contour(x, z, alfsurf[t], 100, colors='black',
linewidth=.5, linestyles='dashed', levels=[1])
plt.clabel(contour,fmt=r'$\mathbf{%.2f}$', fontsize=35)
ssc1=20
velocity = ax.quiver(x[drv21::dv,::dv], z[drv21::dv,::dv], v_x[t,drv21::dv,::dv], v_z[t,drv21::dv,::dv]
, angles='xy',width=0.004, units='width',scale=ssc1, color='red')
velocity4 = ax.quiver(x[drv4::dv4,::dv4], z[drv4::dv4,::dv4], v4_x[t,drv4::dv4,::dv4], v4_z[t,drv4::dv4,::dv4]
, angles='xy',width=0.004, units='width',scale=ssc1, color='black')
ax.quiverkey(velocity, -3, -1.7, 1, '', coordinates='data')
plt.text(-83.3, -8.5, "$\mathbf{%d v_p}$" % facv1,color='red',fontsize=35)
ax.quiverkey(velocity4, -3, -3.5, 1, '', coordinates='data')
plt.text(-83.3, -9., "$\mathbf{%d v_p}$" % facv4,color='black',fontsize=35)
rct=69.6
plt.text(-rct, -8.3, '$\mathbf{|}$',color='black',fontsize=70)
plt.text(-rct-1, -8.8, '$\mathbf{R_{cor}}$',color='black',fontsize=50)
fname = 'z2rhovp.%04d.png' % t
print('Saving frame',fname)
plt.savefig(fname,bbox_inches='tight')
output of python script plot is
My Julia script is
begin
fig=Figure()
ax=Axis(fig[1,1]; xscale=log10, xlabel = "X", ylabel = "Z")
hm = heatmap!(ax, rho[1,:,:].*v_p[1,:,:]; colormap=:jet, interpolate=true)
Colorbar(fig[1, 2], hm; label = "values")
colsize!(fig.layout, 1, Aspect(1, 1.0))
colgap!(fig.layout, 7)
contourf!(psi[1,:,:], levels = 0.3:0.1:1, mode = :relative)
contourf!(alfsurf[1,:,:], levels = 0.3:0.1:1, mode = :relative)
fig
end
Output of Julia script looks like
I have to use two matrices x
and z
which are input for pcolormesh() in Python ; and i have to plot rho[1,:,:].*v_p[1,:,:]
.
What modifications should i do in Julia script?
@juliohm