# Does not plot if change array

**URL:** <https://discourse.julialang.org/t/does-not-plot-if-change-array/82650>\
**Category:** Visualization\
**Tags:** question, modelingtoolkit, symbolics\
**Created:** [June 13, 2022, 1:26am UTC](https://discourse.julialang.org/t/does-not-plot-if-change-array/82650 "2022-06-13T01:26:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![leonandonayre](https://avatars.discourse-cdn.com/v4/letter/l/da6949/32.png) [@leonandonayre](https://discourse.julialang.org/u/leonandonayre)\
**Post date:** [June 13, 2022, 1:26am UTC](https://discourse.julialang.org/t/does-not-plot-if-change-array/82650/1 "2022-06-13T01:26:46Z")

</div>

This program is very simple, but I do not understand why it works when I use `ξ_ar = 0.00001:0.01:10 ` but it does not when `ξ_ar = 0.00001:0.000001:10 `.

```julia
using ModelingToolkit;
using LaTeXStrings;
using Plots;

@variables(begin
ξ
end);

αₙ = 1/(3 + 12ξ - 2sqrt(6ξ*(6ξ+1)))
wₑ = 2/3αₙ - 1
wₑ_bf = ModelingToolkit.build_function(wₑ, ξ, expression=false)

ξ_ar = 0.00001:0.01:10 #This can be plotted, but if I use ξ_ar = 0.00001:0.000001:10 it will not be plotted
wₑ_ar = wₑ_bf.(ξ_ar)
plot(ξ_ar,wₑ_ar,
     title = L"w_{eff} = \frac{2}{3\alpha} - 1",
     color = "blue",
     label = L"\alpha = \frac{1}{3 + 12\xi - 2\sqrt{6\xi\left(6\xi + 1\right)}}",
     linewidth = 2,
     legend = :topright,
     widen = :false,
     xscale = :log10,
     ylim = [0.2,1.1],
     framestyle = :box,
     xaxis = L"\xi",
     yaxis = L"w_{eff}"
     )

```

I have updated Plots.jl and I also ran `] test Plots` and everything seems fine.

This is the julia version I am using:

```julia
PS C:\Users\luisl> julia --version
julia version 1.7.3

```

These are my packages and its versions:

```julia
(@v1.7) pkg> st
      Status `C:\Users\luisl\.julia\environments\v1.7\Project.toml`
  [0c46a032] DifferentialEquations v7.1.0
  [7073ff75] IJulia v1.23.3
  [b964fa9f] LaTeXStrings v1.3.0
  [961ee093] ModelingToolkit v8.14.0
  [91a5bcdd] Plots v1.29.1
  [d1185830] SymbolicUtils v0.19.9
  [0c5d862f] Symbolics v4.6.1
  [1986cc42] Unitful v1.11.0

```

I hope you can help ☹

---

<div class="post-metadata">

**Author:** ![maxkapur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maxkapur/32/21208_2.png) [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Post date:** [June 13, 2022, 4:49am UTC](https://discourse.julialang.org/t/does-not-plot-if-change-array/82650/2 "2022-06-13T04:49:45Z")

</div>

```julia
julia> a = 0.00001:0.000001:10
1.0e-5:1.0e-6:10.0

julia> length(a)
9999991

```

This range has nearly 10 million points in it! Do you really need such a precise plot?

---

<div class="post-metadata">

**Author:** ![leonandonayre](https://avatars.discourse-cdn.com/v4/letter/l/da6949/32.png) [@leonandonayre](https://discourse.julialang.org/u/leonandonayre)\
**Post date:** [June 13, 2022, 6:46am UTC](https://discourse.julialang.org/t/does-not-plot-if-change-array/82650/3 "2022-06-13T06:46:50Z")

</div>

Based on the code I showed that is a good point. Maybe I needed to be more explicit.  
I have been working with ModelingToolkit.jl and DifferentialEquations.jl and I had the same issue. Now, for a case much more simple I get the same problem.  
I wonder if there is something I am missing in order to plot arrays with such a number of points.

---

<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:** [June 13, 2022, 7:02am UTC](https://discourse.julialang.org/t/does-not-plot-if-change-array/82650/4 "2022-06-13T07:02:31Z")

</div>

Your problem is probably you’re trying to plot too many points. There is no real solving that without reducing the number, there will always be some limit to how much stuff you can fit in a plot.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [June 13, 2022, 7:17am UTC](https://discourse.julialang.org/t/does-not-plot-if-change-array/82650/5 "2022-06-13T07:17:00Z")

</div>

You could try to use InspectDR.jl which is pretty good at handling a large number of points as long as you use simple diagram types…

---

<div class="post-metadata">

**Author:** ![maxkapur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maxkapur/32/21208_2.png) [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Post date:** [June 13, 2022, 7:31am UTC](https://discourse.julialang.org/t/does-not-plot-if-change-array/82650/6 "2022-06-13T07:31:03Z")

</div>

If your ultimate goal is just to get a plot of this function, there is no need for ModelingToolkit.

And whether or not you use ModelingToolkit, rather than manually specifying the range of \xi, you might be interested in knowing that you can pass a function directly as the argument to `plot` with the desired x-range and it will figure out a good number of points for you:

```julia
using Plots
α(ξ) = 1/(3 + 12ξ - 2sqrt(6ξ*(6ξ+1)))
w(ξ) = 2/3α(ξ) - 1
plot(w, 0, 10)

```

![fig](https://global.discourse-cdn.com/julialang/original/3X/4/d/4d2644e5a8df0f13f2f2681e2d8cf4cd80b74a65.png)

By inspecting your function, it is clear that increasing the number of points will do little to change the look of this plot: At any normal resolution, 0.000001 on this scale is muuuuch smaller than a pixel.
