Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why doesn't Guide.xticks(ticks=[1:10]) work ? #905

Closed
neilpanchal opened this issue Sep 28, 2016 · 2 comments
Closed

Why doesn't Guide.xticks(ticks=[1:10]) work ? #905

neilpanchal opened this issue Sep 28, 2016 · 2 comments

Comments

@neilpanchal
Copy link

This works:

Guide.xticks(ticks=[1,2,3,4,5,6,7,8,9,10])

But this (the most obvious thing to do) doesn't. My data is in Float64 type.

Guide.xticks(ticks=[1:10])

LoadError: MethodError: no method matching *(::FloatRange{Float64}, ::Measures.Length{:mm,Float64})
Closest candidates are:
  *(::Any, ::Any, !Matched::Any, !Matched::Any...) at operators.jl:138
  *(::AbstractArray{T,N}, !Matched::Number) at abstractarraymath.jl:97
  *(::AbstractArray{T,1}, !Matched::Base.LinAlg.AbstractTriangular{T,S<:AbstractArray{T,2}}) at linalg\triangular.jl:1529
  ...

I have to use collect() function to get it work:

Guide.xticks(ticks=collect(1:10))

I don't know if I am doing something extremely stupid or there no way to use a range object? Guide me please! (pun intended :-) )

As a feedback, I presume the most common thing people want to do is use xticks to increase or decrease the number of ticks or resolution of the axis. That should be the example case instead of the trivial ticks=[0.1, 0.3, 0.5] as documented here: http://gadflyjl.org/stable/lib/guides/guide_xticks.html#Guide.xticks-1

@Mattriks
Copy link
Member

Guide.xticks(ticks=[1:10;]) works. Note the semi-colon.

@tlnagy
Copy link
Member

tlnagy commented Sep 30, 2016

Julia no longer automatically expands ranges, see JuliaLang/julia#3737. Try to compare the output of [1:10] and collect(1:10) on v0.5. @Mattriks' way works because it forces expansion of the range.

We might need to add another example to the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants