# Plot function (from Plots) fails for simple trigonometry

**URL:** <https://discourse.julialang.org/t/plot-function-from-plots-fails-for-simple-trigonometry/104723>\
**Category:** General Usage\
**Created:** [October 8, 2023, 6:29am UTC](https://discourse.julialang.org/t/plot-function-from-plots-fails-for-simple-trigonometry/104723 "2023-10-08T06:29:40Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![StevenSiew](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevensiew/32/218393_2.png) [@StevenSiew](https://discourse.julialang.org/u/StevenSiew)\
**Post date:** [October 8, 2023, 6:29am UTC](https://discourse.julialang.org/t/plot-function-from-plots-fails-for-simple-trigonometry/104723/1 "2023-10-08T06:29:41Z")

</div>

```julia
plot(0:0.1:2pi,[sin(x)^1+cos(x)^1 for x=0:0.1:2pi])

```

gives you

![Screen Shot 2023-10-08 at 5.27.22 PM](https://global.discourse-cdn.com/julialang/original/3X/5/2/526fcbe7194d5e52e52fc5f51f9ddfd2e4cfc5f2.png)

But

```julia
julia> plot(0:0.1:2pi,[sin(x)^2+cos(x)^2 for x=0:0.1:2pi])
┌ Warning: No strict ticks found
└ @ PlotUtils ~/.julia/packages/PlotUtils/bZEEj/src/ticks.jl:191
┌ Warning: No strict ticks found
└ @ PlotUtils ~/.julia/packages/PlotUtils/bZEEj/src/ticks.jl:191

```

gives

![Screen Shot 2023-10-08 at 5.29.03 PM](https://global.discourse-cdn.com/julialang/original/3X/9/5/95de8379a04e163eda2dc131da9db1b07a0bc9f1.png)

---

<div class="post-metadata">

**Author:** ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Post date:** [October 8, 2023, 6:41am UTC](https://discourse.julialang.org/t/plot-function-from-plots-fails-for-simple-trigonometry/104723/2 "2023-10-08T06:41:15Z")

</div>

Looks almost OK for me. It is almost constant, and you can observe the effect of finite precision of Float64 computations. The question is how to define a general default Y scale in this case.

Nevertheless, the number of significant digits for the Y ticks label could be automatically adapted in  
order to produce distinguishable strings…

---

<div class="post-metadata">

**Author:** ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Post date:** [October 8, 2023, 6:55am UTC](https://discourse.julialang.org/t/plot-function-from-plots-fails-for-simple-trigonometry/104723/3 "2023-10-08T06:55:41Z")

</div>

> [@StevenSiew](#):
>
> `0:0.1:2pi,[sin(x)^2+cos(x)^2 for x=0:0.1:2pi])`

FWIW different default behavior is chosen by Makie:

```julia
using CairoMakie
lines(0:0.1:2pi,[sin(x)^2+cos(x)^2 for x=0:0.1:2pi])

```

produces

 ![toto](https://global.discourse-cdn.com/julialang/original/3X/6/5/658719a9817fa4448d62409a20c7c4fe3f715488.png)

---

<div class="post-metadata">

**Author:** ![StevenSiew](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevensiew/32/218393_2.png) [@StevenSiew](https://discourse.julialang.org/u/StevenSiew)\
**Post date:** [October 8, 2023, 10:20am UTC](https://discourse.julialang.org/t/plot-function-from-plots-fails-for-simple-trigonometry/104723/4 "2023-10-08T10:20:30Z")

</div>

> [@LaurentPlagne](#):
>
> Looks almost OK for me. It is almost constant, and you can observe the effect of finite precision of Float64 computations. The question is how to define a general default Y scale in this case.
> 
> Nevertheless, the number of significant digits for the Y ticks label could be automatically adapted in  
> order to produce distinguishable strings…

I am refering to the warning messages

┌ Warning: No strict ticks found  
└ @ PlotUtils ~/.julia/packages/PlotUtils/bZEEj/src/ticks.jl:191  
┌ Warning: No strict ticks found  
└ @ PlotUtils ~/.julia/packages/PlotUtils/bZEEj/src/ticks.jl:191

Those messages should not be there because the plot command is **perfectly** legitimate.

---

<div class="post-metadata">

**Author:** ![bertschi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bertschi/32/33462_2.png) [@bertschi](https://discourse.julialang.org/u/bertschi)\
**Post date:** [October 8, 2023, 10:58am UTC](https://discourse.julialang.org/t/plot-function-from-plots-fails-for-simple-trigonometry/104723/5 "2023-10-08T10:58:03Z")

</div>

The command is legitimate, but the y-range is too small,

```julia
julia> yr = extrema([sin(x)^2+cos(x)^2 for x=0:0.1:2pi])
(0.9999999999999999, 1.0000000000000002)

julia> yr[2] == nextfloat(1.0)
true

```

i.e., there is no space to put any ticks in between.

If you supply a suitable range on your own, the warning disappears:

```julia
plot(0:0.1:2pi,[sin(x)^2+cos(x)^2 for x=0:0.1:2pi]; ylims = (0.9, 1.1))

```

---

<div class="post-metadata">

**Author:** ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Post date:** [October 8, 2023, 2:38pm UTC](https://discourse.julialang.org/t/plot-function-from-plots-fails-for-simple-trigonometry/104723/6 "2023-10-08T14:38:56Z")

</div>

**perfect** then.

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [October 8, 2023, 3:08pm UTC](https://discourse.julialang.org/t/plot-function-from-plots-fails-for-simple-trigonometry/104723/7 "2023-10-08T15:08:47Z")

</div>

I agree with Steven, the way Plots reports the issue is not becoming of production software. The warning (“No strict ticks found”) seems like some internal debugging output meant for developers of Plots. It’s not at all suitable for non-interactive use of Plots (how is one meant to programmatically address a printed warning?), and, on the other hand, it’s not user-friendly enough for interactive use.

On the other hand, I’m not sure that the Plots package is still being actively developed; I’ve never used either Plots or Makie much, but it was my understanding that Makie is meant to replace Plots. Meaning that interface design suggestions would be misplaced with Plots, if it’s not being developed any more, and it would be better to just move to Makie?

---

<div class="post-metadata">

**Author:** ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Post date:** [October 8, 2023, 3:20pm UTC](https://discourse.julialang.org/t/plot-function-from-plots-fails-for-simple-trigonometry/104723/8 "2023-10-08T15:20:28Z")

</div>

I agree. I do not use Plots.jl and always prefer Makie anyway.

Nevertheless, the problem is not specifically related to trigonometry and the fact that the warning mentioning a problem with the ticks is not user-friendly enough should not, IMHO, be flagged as a bug or as a _failure_ of the Plots.jl package.

Finally, although it seems that I did not properly understood the initial question/gripe, I think that it is obvious that I did take some time to answer it in a sunny Sunday morning. Having a **bold** answer when you are just trying to help is not very enjoyable.

---

<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:** [October 8, 2023, 4:51pm UTC](https://discourse.julialang.org/t/plot-function-from-plots-fails-for-simple-trigonometry/104723/9 "2023-10-08T16:51:10Z")

</div>

> [@nsajko](#):
>
> On the other hand, I’m not sure that the Plots package is still being actively developed; I’ve never used either Plots or Makie much, but it was my understanding that Makie is meant to replace Plots.

The latest version, 1.39.0, was released on August 30th, so about 5 weeks ago. In the last 6 months, Plots had 70+ commits from 12 different people. In addition the backends are being developed as well of course, the latest release of the default GR backend was 2 weeks ago.

It’s also ironic that Plots is being dinged in a thread about sub-Float64 accuracy tick issues, given that Makie converts data to Float32 for plotting so it’s normally Makie where people complain about plots going wrong because of issues with floating point accuracy.

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [October 8, 2023, 5:21pm UTC](https://discourse.julialang.org/t/plot-function-from-plots-fails-for-simple-trigonometry/104723/10 "2023-10-08T17:21:04Z")

</div>

OK, thank you for the clarification.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [October 8, 2023, 7:44pm UTC](https://discourse.julialang.org/t/plot-function-from-plots-fails-for-simple-trigonometry/104723/11 "2023-10-08T19:44:28Z")

</div>

> [@nilshg](#):
>
> It’s also ironic that Plots is being dinged in a thread about sub-Float64 accuracy tick issues, given that Makie converts data to Float32

Hehe I didn’t want to say it 😄
