How can I use contour
to plot a contour in an arbitrary shape, say, a parallelogram?
A simple example is:
I tried contour!(xgrid, ygrid, zs)
but it seems contour
can only take vector-like objects, such as range
rather than xgrid
.
By the way, I need to scatter the sampling points uniformly in the parallelogram.
I know it’s not commended to use meshgrid in julia, Dont use Meshgrid function in julia. But how to plot in an arbitrary shape without meshgrid?
Interpolate your scatter points into a grid or compute one and then do like this example except that you’ll have to provide the points of the clipping polygon.
Thanks for reply. I have read the some of the documentation of GMT.jl and I think the most proper way to plot in my case in to use grids as input. From use file instead of grid, I know GMT.jl support inputting grid, but I can’t find the way to do so. Would you please help me with this?
(I can reshape my data into file but that is kind of time consuming.)
A grid in GMT.jl is stored in a GMTgrid type and there is the convenience function mat2grid to help creating a GMTgrid from a plain matrix. One can use (I think) a plain matrix in contourf
but the coordinates will the row and column numbers.
Other from that, if the first argument of contourf
(or any other module that uses grids) is a string then that is interpreted as a file name and the grid is read from disk or, for some formats, the web. A wide range of grid formats is available and automatically recognized.
Linking also this post.