# Basic Dot Plot Error

**URL:** <https://discourse.julialang.org/t/basic-dot-plot-error/78778>\
**Category:** New to Julia\
**Tags:** plotting\
**Created:** [March 31, 2022, 2:02am UTC](https://discourse.julialang.org/t/basic-dot-plot-error/78778 "2022-03-31T02:02:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![YummyPampers2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yummypampers2/32/27328_2.png) [@YummyPampers2](https://discourse.julialang.org/u/YummyPampers2)\
**Post date:** [March 31, 2022, 2:02am UTC](https://discourse.julialang.org/t/basic-dot-plot-error/78778/1 "2022-03-31T02:02:36Z")

</div>

Hello Watchers:

Executing commands in Pluto 0.18.\*  
I am using StatsPlots and PlotlyJS (with plotlyjs()  
activated as a back-end) in Julia 1.8.\*

When executing the following instructions:

```julia
Lab_Entity = ["Lab1", "Lab2", "Lab3", "Lab4", "Lab5"]

trace1 = stp.scatter(
    x=[0.959311, 0.562546, 0.781273, 1.0, 0.176317, 0.176317],
    y=Lab_Entity,
    marker=attr(color="crimson", size=12),
    mode="markers",
    name="CoH",
)
trace2 = stp.scatter(
    x=[0.214919, 0.188576, 0.17397, 0.18988, 0.13302, 0.13302],
    y=Lab_Entity,
    marker=attr(color="gold", size=12),
    mode="markers",
    name="D2C"
)
trace3 = stp.scatter(
    x=[0.0102765, 0.0102765, 0.0104851, 0.0105634, 0.0106416, 0.0106416],
    y=Lab_Entity,
    marker=attr(color="blue", size=12),
    mode="markers",
    name="CR"
)
layout = Layout(title="Compare Plot",
                  xaxis_title="Measurement",
                  yaxis_title="Lab Entity")

stp.plot([trace1,trace2,trace3], layout)

```

This returns the following error:

```julia
MethodError: no method matching getindex(::Nothing, ::Int64)

```

I believe this has something to do with attempting  
to plot a Float64? eltype. Might anyone have a  
work around?

---

<div class="post-metadata">

**Author:** ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)\
**Post date:** [March 31, 2022, 7:05am UTC](https://discourse.julialang.org/t/basic-dot-plot-error/78778/2 "2022-03-31T07:05:55Z")

</div>

You are mixing PlotlyJS syntax with StatsPlots functions, that is not going to work.  
You’d have to use the Plots.jl syntax when using StatsPlots. E.g.

```julia
trace2 = stp.scatter([0.214919, ..., 0.13302], Lab_Entity, marker = (:gold, 12), label = "D2C")

```

etc.

---

<div class="post-metadata">

**Author:** ![YummyPampers2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yummypampers2/32/27328_2.png) [@YummyPampers2](https://discourse.julialang.org/u/YummyPampers2)\
**Post date:** [March 31, 2022, 10:53am UTC](https://discourse.julialang.org/t/basic-dot-plot-error/78778/3 "2022-03-31T10:53:29Z")

</div>

@BeastyBlacksmith – thank you for your reply.

I have rewritten the blocks above as:

```julia
using StatsPlots
   const stp = StatsPlots

Lab_Entity = ["Lab1", "Lab2", "Lab3", "Lab4", "Lab5", "Lab6"]
CH = [0.959311, 0.562546, 0.781273, 1.0, 0.176317, 0.176317]
D2C = [0.214919, 0.188576, 0.17397, 0.18988, 0.13302, 0.13302]
CrR = [0.0102765, 0.0102765, 0.0104851, 0.0105634, 0.0106416, 0.0106416]

trace1 = stp.scatter(
    CH,
    Lab_Entity,
    marker = (:crimson, 12),
    label="CoH",
)
trace2 = stp.scatter(
    D2C,
    Lab_Entity,
    marker = (:gold, 12),
    label="D2C"
)
trace3 = stp.scatter(
    CrR,
    Lab_Entity,
    marker = (:blue, 12),
    label="CR"
)
l = @layout([title="Entity Compare";
            ylab="Measurement";
            xlab="Lab Entity"])

stp.plot([trace1,trace2,trace3], l)

```

Which is returning the error:

```julia
no method matching getindex(::Nothing, ::Int64)

```

I am not iterating over a dictionary, using StatLint  
or JuMP. Could you point out what I am missing?

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [March 31, 2022, 12:30pm UTC](https://discourse.julialang.org/t/basic-dot-plot-error/78778/4 "2022-03-31T12:30:23Z")

</div>

Have you considered my advice from the previous discussion here:

> [@Simple Linear Regression: Domain Error with 0.0](https://discourse.julialang.org/t/simple-linear-regression-domain-error-with-0-0/78717/24):
>
> I think there’s no need to get personal here - I would tend to agree that it would be helpful for OP to consult some introductory statistics/econometrics textbooks to get a better understanding of the methodologies he’s using, but that’s not all that relevant to the concrete question at hand. What I would humbly ask of you, @YummyPampers2, though is to be respectful of other people’s time and effort spent helping him. Practically this means reading [Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757) and fo…

?

Again your piece of code isn’t an MWE that reproduces your problem. In this case it’s possible to fix it (by adding `import StatsPlots as stp` at the top, and fixing the second `scatter` call by adding a comma after `(:gold, 12)`), but again this is just unnecessary overhead for people trying to help you.

The answer to your question is that this

```julia
l = @layout([title="Entity Compare";
            ylab="Measurement";
            xlab="Lab Entity"])

```

still isn’t Plots/StatsPlots syntax, here’s the documentation for layouts:

[https://docs.juliaplots.org/stable/layouts/#Advanced-Layouts](https://docs.juliaplots.org/stable/layouts/#Advanced-Layouts)

---

<div class="post-metadata">

**Author:** ![YummyPampers2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yummypampers2/32/27328_2.png) [@YummyPampers2](https://discourse.julialang.org/u/YummyPampers2)\
**Post date:** [March 31, 2022, 2:25pm UTC](https://discourse.julialang.org/t/basic-dot-plot-error/78778/5 "2022-03-31T14:25:05Z")

</div>

@nilshg

I thought it would be obvious to an  
expert that I was using StatsPlots especially  
since I indicated as much in the opening  
statement of the post. In my case, I provided  
the following instructions:

```julia
using StatsPlots
const stp = StatsPlots

```

I referenced Plots link before you mentioned it  
which is what motivated:

```julia
l = @layout([title="Entity Compare";
            ylab="Measurement";
            xlab="Lab Entity"])

```

I did not mention I was using Pluto  
not the REPL. Which might require  
subtle adjustments to commands in  
some cases. I have updated it.

Lastly, folks default to saying provide a  
MWE, but I have noticed it is not always  
necessary to uncover issues – in this  
case it may be more syntax (spelling),  
logic (command order), rather than some  
more advanced run-time(system-level)  
issue. A professional dev or programmer  
could identify this without having to  
reproduce the code block + problem.
