# Odd point-connection in plots (package vs interactive)

**URL:** https://discourse.julialang.org/t/odd-point-connection-in-plots-package-vs-interactive/78271
**Category:** New to Julia
**Tags:** plotting, plots
**Created:** [March 22, 2022, 12:30pm UTC](https://discourse.julialang.org/t/odd-point-connection-in-plots-package-vs-interactive/78271 "2022-03-22T12:30:24Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![dankelley](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dankelley/32/33539_2.png) [@dankelley](https://discourse.julialang.org/u/dankelley)
#### Post date: [March 22, 2022, 12:30pm UTC](https://discourse.julialang.org/t/odd-point-connection-in-plots-package-vs-interactive/78271/1 "2022-03-22T12:30:24Z")

</div>

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 [https://github.com/dankelley/oceanography](https://github.com/dankelley/oceanography). 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_

```julia
# 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)
savefig("04_plot_problem.png")

```

![04_plot_problem](https://global.discourse-cdn.com/julialang/original/3X/5/7/57ce562102697651f04bbc4ff2de86128c214999.png)

---

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [March 22, 2022, 12:55pm UTC](https://discourse.julialang.org/t/odd-point-connection-in-plots-package-vs-interactive/78271/2 "2022-03-22T12:55:14Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [March 22, 2022, 2:35pm UTC](https://discourse.julialang.org/t/odd-point-connection-in-plots-package-vs-interactive/78271/3 "2022-03-22T14:35:44Z")

</div>

The code is in his repository, I just hope the last commit is the same version used for the plots. See: [https://github.com/dankelley/oceanography/blob/a71b2f71582f089cd1bc442218179138b87262c1/Oceanography/src/Oceanography.jl#L40](https://github.com/dankelley/oceanography/blob/a71b2f71582f089cd1bc442218179138b87262c1/Oceanography/src/Oceanography.jl#L40)

---

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [March 22, 2022, 3:01pm UTC](https://discourse.julialang.org/t/odd-point-connection-in-plots-package-vs-interactive/78271/4 "2022-03-22T15:01:10Z")

</div>

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

---

<div class="post-metadata">

### Author: ![dankelley](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dankelley/32/33539_2.png) [@dankelley](https://discourse.julialang.org/u/dankelley)
#### Post date: [March 22, 2022, 4:13pm UTC](https://discourse.julialang.org/t/odd-point-connection-in-plots-package-vs-interactive/78271/5 "2022-03-22T16:13:58Z")

</div>

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.

Dan.
