Hello, and happy (almost) New Year.,
First, I’ll apologize for a long-winded question…
I am a longtime R user who is gradually moving to Julia. As an oceanographer, a common task I have is to make image plots of a water property (e.g. temperature) as a function of a horizontal coordinate (e.g. geographic latitude) and depth. We plot such diagrams with depth, a positive number, on the y axis.
Since we want the top of the plot to represent the ocean surface, we want the y axis to decrease upwards, so I assume I ought to use yflip=true in my call to heatmap(). That works fine for me. However, a very common task is to want to limit the view to just say the top 1/4 of the water column, and that is where I get a problem.
Assume ocean depth is 4000 metres. To get the top 1000m, I tried heatmap(..., yflip=true, ylim=(0,1000) but that shows the range from 4000m to 3000m, not the desired range from 1000m to 0m.
I can trick things by using YLIM=ylims() to find the limits of the plot, and then use heatmap(..., ylim=YLIM2].-[1000, 0]) which gives the correct image, but of course then the axes are wrong.
I am using the GR plotting scheme in Julia version 1.12.3 on a mac running Tahoe 26.3.
I wonder whether this is something that is familiar to other users, with a simple fix.
I’m uploading sample code and results, in case that helps. (I cannot see how to upload the .jld2 file, though, and creating that file requires a reader to install software, download oceanographic data files, etc.)
In the image I’ve attached, the top panel is the full-depth view of ocean salinity, with lines drawn 1000m below the surface and 1000m above the deepest point. The middle panel is what I had hoped would work, but inspection with respect to the top panel indicates that it is actually showing the bottom 1000m. The bottom panel is what I get by fiddling ylim, which gives me the view I want (again, see the lines in the top panel) but of course the y axis is wrong. I could fake things by not drawing that axis, but I want to be able to later add annotations to the diagram, so proper values of y are important to me.
I’m sorry for the length of this question.
heatmap_question.jl (662 Bytes)

