# Learning Plots... now: marker\_z?

**URL:** <https://discourse.julialang.org/t/learning-plots-now-marker-z/9996>\
**Category:** Visualization\
**Created:** [March 26, 2018, 7:56pm UTC](https://discourse.julialang.org/t/learning-plots-now-marker-z/9996 "2018-03-26T19:56:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [March 26, 2018, 7:56pm UTC](https://discourse.julialang.org/t/learning-plots-now-marker-z/9996/1 "2018-03-26T19:56:56Z")

</div>

I’m trying to learn Plots, and now: the marker\_z keyword.

With

xm=randn(100);  
ym=randn(100);

the following two commands (pyplot backend) give almost the same plots:

scatter(xm,ym)  
plot(xm,ym, markershape=:circle,linecolor=false)

HOWEVER:

scatter(xm,ym,marker\_z=1:100)

works, while:

plot(xm,ym, markershape=:circle,linecolor=false,marker\_z=1:100)

fails miserably.

Why?

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [March 26, 2018, 8:07pm UTC](https://discourse.julialang.org/t/learning-plots-now-marker-z/9996/2 "2018-03-26T20:07:33Z")

</div>

I should add…

plot(xm,ym, markershape=:circle,linecolor=false,marker\_z=1:100)

does in fact work if I use the gr backend… [not quite, though: the legend is wrong: black, filled marker, and the line is included in the marker… maybe I should set the linecolor differently?]

---

<div class="post-metadata">

**Author:** ![JackDevine](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jackdevine/32/1048_2.png) [@JackDevine](https://discourse.julialang.org/u/JackDevine)\
**Post date:** [March 26, 2018, 8:28pm UTC](https://discourse.julialang.org/t/learning-plots-now-marker-z/9996/3 "2018-03-26T20:28:02Z")

</div>

It is weird that GR and PyPlot give different answers here…

That said, I am not precisely sure of what you expected to happen. If you just use

```julia-auto
plot(xm,ym,seriestype=:scatter,markershape=:circle,linecolor=false,marker_z=1:100)

```

then you will find that the code will work the same on both backends. The difference here is that I added `seriestype=:scatter`. So the moral of the story is that `scatter` and `plot` do different things.

From the documentation:

> `line_z` and `marker_z` parameters will map data values into a `ColorGradient` value

I hope that this helps.

PS: Have a look at this post on backticks

> [@PSA: how to quote code with backticks](https://discourse.julialang.org/t/psa-how-to-quote-code-with-backticks/7530):
>
> This is a short post on how to use backticks (` and ```) to quote code, so it is easy to read. This post can be linked to new users who are confused by this feature. Why By quoting your code, you get a monospaced font (which preserves indentation) and syntax highlighting. This makes it easier to read your code and help you. Displayed code looks like this: function displayed\_code(x::Int, y::Int) if x \< y println("x is smaller") else println("or not") end end Inline…

It allows you to get your code looking beautiful on discourse. It might help if you try asking a more complex question.

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [March 26, 2018, 8:54pm UTC](https://discourse.julialang.org/t/learning-plots-now-marker-z/9996/4 "2018-03-26T20:54:59Z")

</div>

Thanks for quick answer and tip on backtics!

OK – so `seriestype=:scatter` fixes this, and reduces the need to set `linecolor=false`. Apart from this, I would have guessed that `scatter` was just a shorthand for `plot` with defined `markershape` and `linecolor` set to `false`. So there must be more to `scatter`…?

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [March 26, 2018, 8:59pm UTC](https://discourse.julialang.org/t/learning-plots-now-marker-z/9996/5 "2018-03-26T20:59:09Z")

</div>

`scatter(...)` is short for `plot(..., seriestype = :scatter)`. You should set the seriestype rather than mess around with markershape etc.  
Also, `linecolor` is an alias for `seriescolor`, i.e. it will also affect the color of markers. Don’t use `linecolor = false` to hide the line.

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [March 27, 2018, 7:24am UTC](https://discourse.julialang.org/t/learning-plots-now-marker-z/9996/6 "2018-03-27T07:24:18Z")

</div>

Thanks for clarification: I guess that my “problem” of wanting to set both linestyle and marker (in the default `seriestype`, stems from by MATLAB background…).

Is `linecolor` really an alias for `seriescolor`? To me, the documentation seems to indicate that `linecolor` by default _inherits_ from `seriescolor`, but may be set to be different:

![image](https://global.discourse-cdn.com/julialang/original/3X/3/7/378117ae3bd4445d22d2763b0837335102c8f460.png)

Btw: this inserted screen capture is from Firefox (it is similar in MS Edge), and illustrates a problem with the documentation… the Description cell for `linestyle` doesn’t show fully, and it is not possible to scroll sideways. The only way to see what follows after `:dashd..` is to attempt to copy the cell content and paste it into an editor.

---

<div class="post-metadata">

**Author:** ![daschw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/daschw/32/2926_2.png) [@daschw](https://discourse.julialang.org/u/daschw)\
**Post date:** [March 27, 2018, 12:33pm UTC](https://discourse.julialang.org/t/learning-plots-now-marker-z/9996/7 "2018-03-27T12:33:23Z")

</div>

Thanks for reporting @BLI ! This should be fixed for pyplot in [https://github.com/JuliaPlots/Plots.jl/pull/1460](https://github.com/JuliaPlots/Plots.jl/pull/1460).
