Odd point-connection in plots (package vs interactive)

I’m an oceanographer with quite a lot of experience in R, and I’m doing some computations in Julia (rather than C, my old standby), so I’d like to be able to make oceanographic plots in Julia. I’m sure my methods are terrible, but in any case they are at GitHub - dankelley/oceanography: Julia code for oceanographic analysis. In that directory, there is a demo file named 04_plot_problem.jl, which shows something that confuses me.

Background for this type of plot. This diagram type is a way to display data measured by an instrument that is lowered into the ocean. We measure something (in this case, salt concentration, called “Practical Salinity”) as an instrument falls through the water column. This quantity goes on the x axis, and we place that axis at the top of the page. On the y axis, we put pressure, with high values at the bottom of the page. Thus, the diagram is a sort of sketch of the ocean, viewed from the side, which is why we call these “profile plots”.

From the above, I need to supply plot() with yaxis=:flip and xmirror=true.

I am attaching a snapshot with 2 panels. On the left, I do a simple plot call. I’m putting the full code below, above the plot. This panel has the expected appearance. On the right, I have a plot created with plotProfile() in my trial Oceanography package. The plot call is basically the same; most of the code in that function is to handle other variables. Notice the odd connection of points in that right panel. It’s like it’s trying to join them vertically, instead of horizontally.

I wonder if anyone has an idea what’s going on here. The interactive code works right, but not the code in my library.

Please note that I’m a newbie. I don’t even know how to try out different plotting systems (and am a bit mystified by which I ought to select). The one I’m using is pretty heavy.

I apologize for not boiling this down more, and for relying on the kindness of strangers, with what I fear is an elementary question betraying my ignorance (e.g. I am not wholly sure how to update my package, with the various ] commands).

Sample code

# Demo plot problem.
using CSV, DataFrames, Plots
import Pkg; Pkg.activate("Oceanography")
using Oceanography

csv = CSV.read("ctd.csv", DataFrame)
ctd = Ctd(csv.salinity, csv.temperature, csv.pressure)
S = ctd.salinity
T = ctd.temperature
p = ctd.pressure
p1 = plot(S, p, yaxis=:flip, xmirror=true, legend=false)
p2 = plotProfile(ctd; which="S")
plot(p1, p2)


We cannot see what is within plotProfile(), but by chance do you do any data sorting before plotting?

The code is in his repository, I just hope the last commit is the same version used for the plots. See: oceanography/Oceanography.jl at a71b2f71582f089cd1bc442218179138b87262c1 · dankelley/oceanography · GitHub

1 Like

The culprit is the plot argument seriestype=:line.
I think you want to use the default seriestype=:path

1 Like

Thanks very much, @rafael.guerra. I have much to learn about Julia graphics, and I appreciate the help that you, and @henrique_becker have so kindly provided.