# An internal Julia plotting package?

**URL:** <https://discourse.julialang.org/t/an-internal-julia-plotting-package/73079>\
**Category:** Internals & Design\
**Tags:** question\
**Created:** [December 14, 2021, 3:12pm UTC](https://discourse.julialang.org/t/an-internal-julia-plotting-package/73079 "2021-12-14T15:12:31Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![laborg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laborg/32/5474_2.png) [@laborg](https://discourse.julialang.org/u/laborg)\
**Post date:** [December 15, 2021, 9:12am UTC](https://discourse.julialang.org/t/an-internal-julia-plotting-package/73079/41 "2021-12-15T09:12:34Z")

</div>

> [@rafael.guerra](#):
>
> The most annoying thing is to have to learn several “plotting languages” on the same julia platform, to achieve exactly the same thing.

Why would you want to achieve exactly the same thing twice but with a different language?

Although I use Plots.jl I personally don’t buy into the unified syntax story. Makie looks more promising in this regard because the backend abstraction is not based on existing languages but on hardware/drivers.

---

<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:** [December 15, 2021, 9:45am UTC](https://discourse.julialang.org/t/an-internal-julia-plotting-package/73079/42 "2021-12-15T09:45:28Z")

</div>

> [@laborg](#):
>
> I personally don’t buy

Maybe a rental analogy will do the trick: when you rent a car in the US or Europe, you don’t expect to have to pedal to open the trunk or to sing a local song to get the car started. It is reassuring that at least the basic controls are the same everywhere.

---

<div class="post-metadata">

**Author:** ![ptoche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ptoche/32/23554_2.png) [@ptoche](https://discourse.julialang.org/u/ptoche)\
**Post date:** [December 15, 2021, 10:37am UTC](https://discourse.julialang.org/t/an-internal-julia-plotting-package/73079/43 "2021-12-15T10:37:32Z")

</div>

> [@lmiq](#):
>
> I have been using Plots with GR

I agree. In its current iteration, the Julia “go-to” `Plots` package is amazing. ❤

What I do find difficult to follow is how all the plotting packages and backends fit with one another. In fact I’m so confused that I haven’t dared to go outside of `Plots` for the “publication-ready” stuff. (Oh and publication-ready is very much a subjective, field-dependent concept: some horrible plots do get published)

If someone in the know contributed a flow chart to illustrate which package to turn to according to need, it would greatly help our understanding of the Julia plotting universe. For instance, if you need a map, use X, Y. If you need 3D, use Y,Z. Etc.

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [December 15, 2021, 11:24am UTC](https://discourse.julialang.org/t/an-internal-julia-plotting-package/73079/44 "2021-12-15T11:24:33Z")

</div>

There is such a table for Plots.jl backends. [Backends · Plots](http://docs.juliaplots.org/latest/backends/)

I’m sure most of those points apply for the packages the backends are based on too. The problem with comparing between frontends is most (advanced) users have committed. And even if you had a good objective comparison it’s likely to age poorly as the packages develop.

Personally I couldn’t speak to Makie, for instance, because I’ve dug down pretty hard in the Plots/GR camp.

---

<div class="post-metadata">

**Author:** ![ptoche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ptoche/32/23554_2.png) [@ptoche](https://discourse.julialang.org/u/ptoche)\
**Post date:** [December 15, 2021, 12:05pm UTC](https://discourse.julialang.org/t/an-internal-julia-plotting-package/73079/45 "2021-12-15T12:05:55Z")

</div>

> [@gustaphe](#):
>
> There is such a table for Plots.jl backends. [Backends · Plots](http://docs.juliaplots.org/latest/backends/)

Nice! I thought you were going to direct me to:

 ![](https://global.discourse-cdn.com/julialang/original/3X/1/6/1658e42c9e5c242e3ef022de6ffb8c329758e8c0.png)

---

<div class="post-metadata">

**Author:** ![anon28281882](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@anon28281882](https://discourse.julialang.org/u/anon28281882)\
**Post date:** [December 15, 2021, 8:58pm UTC](https://discourse.julialang.org/t/an-internal-julia-plotting-package/73079/46 "2021-12-15T20:58:44Z")

</div>

@leon, It seems to be not the first time you are rising this topic. Is there any conclusion / summary of this and your previous conversations wrt your experience with Julia and Matlab? What do you think? IMO, even a few summary sentences would be interesting / useful in the near or long - term timeframe.

---

<div class="post-metadata">

**Author:** ![anon28281882](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@anon28281882](https://discourse.julialang.org/u/anon28281882)\
**Post date:** [December 16, 2021, 6:24pm UTC](https://discourse.julialang.org/t/an-internal-julia-plotting-package/73079/47 "2021-12-16T18:24:03Z")

</div>

From my point of view, based on limited knowledge about all historical developments, I understand that Plots.jl was designed to somehow fulfill your suggestion. However, it seems that there was a will and a need for creation of other plotting packages that are not integrated with it. In general, I see it as a versatile world of Julia plotting. It has its advantages but also disadvantages. The main disadvantage for me is that I have to learn new things when I discover that some other package is providing abilities or ease of use that the one I am currently using is lacking. On the other side, I believe that such approach is moving things constantly forward. Having said it, I do believe that currently there is a way to solve a problem of “creating a figure with multiple subplots” when different packages are used, also at a level required for pro publications. At the same time, what I mentioned earlier, I would happily see a better support for basic geo plotting in the other packages than GMT and VegaLite. I believe for most of the people interested in geo plots, similar abilities as provided by VegaLite would be mostly sufficient. As addition, I will also allow myself to mention external package named [kepler.gl](https://kepler.gl) that is not natively supported by Julia but is providing some abilities that are rather not present with any of Julia plotting packages currently. As a side note, I would like to strongly underline that I really had nothing wrong on my mind when addressing @carstenbauer a few posts above. Actually, I have to admit that I like his style of conversation very much, much better than sometimes suggested here so called niceties. 😉

---

<div class="post-metadata">

**Author:** ![leon](https://avatars.discourse-cdn.com/v4/letter/l/dc4da7/32.png) [@leon](https://discourse.julialang.org/u/leon)\
**Post date:** [December 17, 2021, 2:03pm UTC](https://discourse.julialang.org/t/an-internal-julia-plotting-package/73079/48 "2021-12-17T14:03:25Z")

</div>

Many thanks all for the great discussion.

I look forward to being able to plot figures like the below using GMT.jl in multiple subplots:  
[https://www.nature.com/articles/s41598-019-55039-4/figures/7](https://www.nature.com/articles/s41598-019-55039-4/figures/7)

Also this one with one GMT.jl plotted map and another regular xy plot:  
[https://www.nature.com/articles/s41598-019-55039-4/figures/4](https://www.nature.com/articles/s41598-019-55039-4/figures/4)

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [December 17, 2021, 2:30pm UTC](https://discourse.julialang.org/t/an-internal-julia-plotting-package/73079/49 "2021-12-17T14:30:12Z")

</div>

To start with, we must know the name of that projection. I though I knew but was wrong. Also, I’m not sure those plots were made with GMT. The use of the _parula_ color scale make me think they were made with Matlab.

Search on the PROJ docs if you find that projection.

---

<div class="post-metadata">

**Author:** ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Post date:** [December 17, 2021, 4:48pm UTC](https://discourse.julialang.org/t/an-internal-julia-plotting-package/73079/50 "2021-12-17T16:48:37Z")

</div>

@Leon Just because those figures from the paper look nice I tried to replicate them with [GeoMakie](https://github.com/JuliaPlots/GeoMakie.jl) which is about to also have some major changes. For now, the following kinda works with scatters, (heatmaps and surfaces still are a problem, which I hope also get fixed in the next Makie release, don’t know really, @sdanisch probably will know better). Either way, here the code and the output 😃

 ![GoodH](https://global.discourse-cdn.com/julialang/original/3X/4/5/4551e9c288cd8b45bf391d10225d91f4d13e1251.png)

```julia
using GeoMakie, CairoMakie
using Proj4, GeometryBasics, GeoDatasets

lonmask, latmask, data = GeoDatasets.landseamask(; resolution = 'c', grid = 10)
fig = Figure(resolution = (900, 1000), fontsize = 22)
ax1 = Axis(fig[1, 1], aspect = DataAspect(), title = "Projection: Goode H")
ax2 = Axis(fig[2, 1], aspect = DataAspect())
ax3 = Axis(fig[3, 1:2], xlabel = "date", ylabel = "y label")

# all this will go in the next release of GeoMakie
trans = Proj4.Transformation("+proj=longlat +datum=WGS84",
    "+proj=igh_o +lon_0=-160", always_xy = true)
ptrans = Makie.PointTrans{2}(trans)

ax1.scene.transformation.transform_func[] = ptrans
ax2.scene.transformation.transform_func[] = ptrans

# add some limits, still it needs to be manual
lats = -90:30.0:90 |> collect
lons = -180:30.0:180 |> collect
# avoid PROJ wrapping 180 to -180
lons[end] = prevfloat(lons[end])
points = [Point2f0(lon, lat) for lon in lons, lat in lats]
xytrans = Makie.apply_transform(ptrans, points)
function checkInfs(xy)
    xy != [Inf, Inf] && xy != [-Inf, -Inf] && xy[1] != Inf && xy[2] != Inf && xy[1] != -Inf && xy[2] != -Inf
end
xytransClean = [1.15xytrans[i] for i in 1:prod(size(xytrans)) if checkInfs(xytrans[i])]
rectLimits = FRect2D(xytransClean)
limits!(ax1, rectLimits)
limits!(ax2, rectLimits)
# up to here things will go into the GeoMakie internals

field = [Point3f(lonmask[i], latmask[j], 0) for i = 1:3:length(lonmask) for j = 1:3:length(latmask)]
color1 = [Float64(data[i, j]) == 0.0 ? -rand() : Float64(data[i, j]) for i = 1:3:length(lonmask) for j = 1:3:length(latmask)]
color2 = [Float64(data[i, j]) == 0.0 ? -1 - rand() : Float64(data[i, j]) for i = 1:3:length(lonmask) for j = 1:3:length(latmask)]
mncolor = minimum(minimum.([color1, color2]))
mxcolor = maximum(maximum([color1, color2]))
hm = scatter!(ax1, field, color = color1, colorrange = (mncolor, mxcolor),
    colormap = :CMRmap, markersize = 3)
scatter!(ax2, field, color = color2, colorrange = (mncolor, mxcolor),
    colormap = :CMRmap, markersize = 3)
scatterlines!(ax3, 1 .. 10, x -> x^2)
Colorbar(fig[1:2, 2], hm, label = "some random label", width = 40, height = Relative(0.75))
hidedecorations!(ax1)
hidedecorations!(ax2)
hidespines!(ax1)
hidespines!(ax2)
save("GoodH.png", fig)
fig

```

---

<div class="post-metadata">

**Author:** ![leon](https://avatars.discourse-cdn.com/v4/letter/l/dc4da7/32.png) [@leon](https://discourse.julialang.org/u/leon)\
**Post date:** [December 17, 2021, 5:13pm UTC](https://discourse.julialang.org/t/an-internal-julia-plotting-package/73079/51 "2021-12-17T17:13:18Z")

</div>

@lazarusA,

Thank you so much for sharing! 👍 👍 Over the years, I find the most effective way of learning a new tool is through a good working example. I’m sure a lot of people will find the sample code to be super useful.

Does `GeoMakie` allow a user to add GMT based plots to its subplots yet?

---

<div class="post-metadata">

**Author:** ![anon28281882](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@anon28281882](https://discourse.julialang.org/u/anon28281882)\
**Post date:** [December 17, 2021, 5:33pm UTC](https://discourse.julialang.org/t/an-internal-julia-plotting-package/73079/52 "2021-12-17T17:33:25Z")

</div>

> [@lazarusA](#):
>
> `all this will go in the next release of GeoMakie`

So I understand that GeoMakie is going to be in active development again, right?

Is the any estimated date for the next release?

Is GeoMakie going to be a separate project or is there a chance that GeoMakie will become a part of Makie with long term support?

---

<div class="post-metadata">

**Author:** ![leon](https://avatars.discourse-cdn.com/v4/letter/l/dc4da7/32.png) [@leon](https://discourse.julialang.org/u/leon)\
**Post date:** [December 17, 2021, 5:34pm UTC](https://discourse.julialang.org/t/an-internal-julia-plotting-package/73079/53 "2021-12-17T17:34:05Z")

</div>

@joa-quim,

I think it is called `interrupted mollweide` or something like that. It would be awesome if you could figure out how to plot such a map using `GMT.jl`. After all, GMT seems to be capable of producing the most vividly beautiful maps.

Below is my code to draw such a map in Matlab using the [M\_Map](https://www.eoas.ubc.ca/~rich/map.html) package. It plots the map piecemeal in 6 steps.

```julia
hold on;
set(gca,'xlimmode','auto','ylimmode','auto');
Slongs=[-100 43;-75 20; 20 145;43 100;145 295;100 295];
Slats= [0 90;-90 0;-90 0; 0 90;-90 0; 0 90];
for l=1:6,
    m_proj('mollweide','long',Slongs(l,:),'lat',Slats(l,:));
    m_grid('fontsize',6,'xticklabels',[],'xtick',[-180:30:360],...
        'ytick',[-80:20:80],'yticklabels',[],'linest','-','color','k');
    
    [C1, h1] = m_contourf (X, Y, Z, [5:0.01:10], 'LineStyle', 'none' );
    [C1, h1] = m_contourf (X-360, Y, Z, [5:0.01:10], 'LineStyle', 'none' );
    
    m_coast('patch',[.8 .8 .8]);
    
end;
set(gca,'xlimmode','auto','ylimmode','auto');

```

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [December 17, 2021, 6:28pm UTC](https://discourse.julialang.org/t/an-internal-julia-plotting-package/73079/54 "2021-12-17T18:28:22Z")

</div>

OK, so the problems. GMT has quite a lot o projections but nothing comparing to PROJ. It is in our plans to adopt PROJ for all the projections and in fact for point projections users can already use PROJ by using its syntax. Even for reprojecting images its is possible to use PROJ and _all_ of its projections (not exactly true), but there is no mechanism to generate the frames and annotations for non-supported (by the GMT engine) projections. And the bad news is that the `Interrupted Mollweide` and `Interrupted Good Homolosine` are not supported projections. It should be possible to come out with a similar plot as shown by @lazarusA by plotting many points but I won’t go into the trouble of trying that.

A possible solution would be to try similar to what you do with M\_Map and seeking inspiration in the `Interrupted Sinusoidal` example [here](https://www.generic-mapping-tools.org/GMT.jl/dev/proj_examples/#Sinusoidal)

---

<div class="post-metadata">

**Author:** ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)\
**Post date:** [December 17, 2021, 8:29pm UTC](https://discourse.julialang.org/t/an-internal-julia-plotting-package/73079/55 "2021-12-17T20:29:59Z")

</div>

Ok, this is fun and interesting! I just took another look at the vega ecosystem, and I think with a few more tweaks to our Julia package we could make everything in [https://github.com/d3/d3-geo-projection](https://github.com/d3/d3-geo-projection) available as part of VegaLite.jl. And I think that also allows one to specify custom projections relatively easily. So my best guess is that one could take one of the projects in d3-geo-projection as a starting point (say `geoInterruptedMollweide`) and then customize it so that it looks like the example above.

---

<div class="post-metadata">

**Author:** ![EvoArt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evoart/32/25357_2.png) [@EvoArt](https://discourse.julialang.org/u/EvoArt)\
**Post date:** [December 17, 2021, 8:37pm UTC](https://discourse.julialang.org/t/an-internal-julia-plotting-package/73079/56 "2021-12-17T20:37:24Z")

</div>

If you are comfortable using LaTeX, I would honestly just make all your maps and subplots separately without axes. Then put them in a figure using pgfplots `\addplot graphics`. E.g. [How do I fit a graphic exactly to an axis in pgfplots? - TeX - LaTeX Stack Exchange](https://tex.stackexchange.com/questions/394873/how-do-i-fit-a-graphic-exactly-to-an-axis-in-pgfplots)  
That, or play around with saving subplots as images and doing something similar in Makie.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [December 18, 2021, 6:17pm UTC](https://discourse.julialang.org/t/an-internal-julia-plotting-package/73079/57 "2021-12-18T18:17:52Z")

</div>

Well, we can still do nice plots like this but it’s not general enough to be very useful when data does not span on on land and oceans.

Here’s an example with bathymetry, but still struggling on how to manually make a frame.

```julia
using GMT

G = gmtread("@earth_relief_10m");
G2 = gdalwarp(G, ["-s_srs", "+proj=latlong", "-t_srs", "+proj=igh_o +lon_0=-160", "-dstnodata", "NaN"]);
imshow(G2, colorbar=true, shade=true, frame=:none)

```

 ![GMTjl_tmp-fs8](https://global.discourse-cdn.com/julialang/original/3X/0/5/0522537c37f19cb2724a811a181f4b6149416397.jpeg)

---

<div class="post-metadata">

**Author:** ![leon](https://avatars.discourse-cdn.com/v4/letter/l/dc4da7/32.png) [@leon](https://discourse.julialang.org/u/leon)\
**Post date:** [December 20, 2021, 3:34pm UTC](https://discourse.julialang.org/t/an-internal-julia-plotting-package/73079/58 "2021-12-20T15:34:32Z")

</div>

@joa-quim

It’s great to see GMT can do this type of plotting! Unfortunately, when I tested the code, I got something very different. See attached.

 ![GMTjl_tmp](https://global.discourse-cdn.com/julialang/original/3X/f/8/f80a231affe285ea09aecfc17fd9b2e47c236637.jpeg)

On a related question, does GMT allow subplots, so that I could plot 3 maps as shown in Figure 7 ([https://www.nature.com/articles/s41598-019-55039-4/figures/7](https://www.nature.com/articles/s41598-019-55039-4/figures/7))? The projection does not have to be in interrupted Mollweide though.

> [@joa-quim](#):
>
> ```julia
> using GMT
> 
> G = gmtread("@earth_relief_10m");
> G2 = gdalwarp(G, ["-s_srs", "+proj=latlong", "-t_srs", "+proj=igh_o +lon_0=-160", "-dstnodata", "NaN"]);
> imshow(G2, colorbar=true, shade=true, frame=:none)
> 
> ```

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [December 20, 2021, 6:52pm UTC](https://discourse.julialang.org/t/an-internal-julia-plotting-package/73079/59 "2021-12-20T18:52:48Z")

</div>

You clearly plotted the geographic grid (`G` in my example) instead of the projected one (`G2`)

> [@leon](#):
>
> does GMT allow subplots

Yes. I even posted a link in one my posts in this thread.  
It has also the very convenient options `xshift` and `yshift`

---

<div class="post-metadata">

**Author:** ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)\
**Post date:** [December 20, 2021, 7:12pm UTC](https://discourse.julialang.org/t/an-internal-julia-plotting-package/73079/60 "2021-12-20T19:12:49Z")

</div>

Does that use Jet as the default colormap? It has been replaced in many packages with “perceptually uniform” colormaps. See [matplotlib colormaps](https://bids.github.io/colormap/) for more info.

[Previous page](https://discourse.julialang.org/t/an-internal-julia-plotting-package/73079.md?page=2)

[Next page](https://discourse.julialang.org/t/an-internal-julia-plotting-package/73079.md?page=4)
