Python pcolormesh() alternative in JULIA --`Makie.convert_arguments` for the plot type MakieCore.Heatmap and its conversion trait MakieCore.CellGrid() was unsuccessful

I am using x,z as shown below in heatmap() input. I am getting error Makie.convert_arguments for the plot type MakieCore.Heatmap and its conversion trait MakieCore.CellGrid() was unsuccessful.


My code is :point_down:

begin
	fig=Figure()
	ax=Axis(fig[1,1]; xscale=log10, xlabel = "X", ylabel = "Z")
	hm = heatmap!(ax,x,z, 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

How can i use Plot Recipes · Makie ? How to overcome this error?

Heatmap does not accept x and y coordinates as grids - only vectors. Use surface instead!

I have to change coordinates from Spherical to Cartesian system. I want to use vectors x and y.

X and Y are matrices here, no?

Yes, X and Y are matrices here. But Python heatmap() function works fine on that matrix. I am converting Python script to Julia. I also have to add contours in plot.
@rafael.guerra
@joa-quim

Makie has a different definition of heatmaps than python. Is there a particular issue with surface?

My Python heatmap looks like as shown in Plotting Heatmap with many attributes

Python heatmap() function is taking input of x and y as matrices. How can i get such heatmap in Julia? In Julia heatmap() function don’t accept x qnd y input as matrices.

Well, you pinged me, so in order that I may help you must start trying to do that image with GMT. Start by converting your data array into GMTgrid (make it Float32), use grdimage, overlay, grdcontour layers.

Yes, Now i have added GMT.jl. How can i get Python plot like in Plotting Heatmap with many attributes ?
See What i have done so far :point_down:


@rafael.guerra
@joa-quim

Still don’t understand what you are trying to achieve. To reproduce exactly that other figure? Make one alike but using your own data?

Anyway, in the mat2grid step you should also include the x=... and y=... options with the data coordinate vectors. Than the figure is made with a base grdimage call, followed with a grdcontour and a quiver layers. And a plot layer too (I think) to add the dashed lines.

x and y are matrices and not vector. I want to get plot like :point_down:

and then add quivers etc.
@asinghvi17
@jules

If they are matrices and your grid is regular that’s the (meshgrid) awful waste. A vector of x and y is all it needs. Extract them from the x,y matrices. But I see that your contour plot already has coordinates, so you must have set them already.
Again, start with an image made with grdimage and add the other layers.

How to extract those vectors from x and y matrices? I don’t know which part of matrix contains those vectors. You can see my matrix

I’m afraid there some misunderstandings here and I know nothing about your grid. I am assuming that whatever is represented in your matrix it has coordinates, right? Then pass those x,y coordinates as vectors to the mat2grid function. If no coordinates in mat2grid it will create default ones based on the nrows, ncols of the matrix.

Please see matrix above. In python pcolormesh() function is working fine on that matrix. Is there any alternative way to get that pcolormeshin Julia?

OK, you have no coordinates.

Why don’t you try what I’ve been telling you? Start with grdimage(......)

I have two matrices x and y. SORRY for mistake , I need alternative of pcolormesh() of Python and not heatmap().

Then make the image with one of those layers.

GMT has a pcolor but don’t think it will be better than making an image with grdimage.

1 Like