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

behaviour of makecpt #1198

Closed
liming-he opened this issue Jun 19, 2023 · 8 comments
Closed

behaviour of makecpt #1198

liming-he opened this issue Jun 19, 2023 · 8 comments

Comments

@liming-he
Copy link

See below the output.

I expect to see different colours for Row #1 and R#2; however, Row #1 and Row #2 are in the same colour.

The first example is from: https://docs.juliahub.com/GMT/EoU0j/0.29.0/makecpt/#Discrete-versus-Continuous-CPT

Is this a bug, or did I misunderstand the example? Many thanks. -LH.

julia> makecpt(cmap=(:red,:green,:blue), range=[0,100,300,1000], no_bg=true)
Extract of a GMTcpt exposed as a GMTdataset for display. Colors converted to [0-255]
Model: rgb
Color depth: 24
3×9 GMTdataset{Float64, 2}
Row │ r1 g1 b1 r2 g2 b2 alpha z1 z2
│ Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64
─────┼─────────────────────────────────────────────────────────────────────────────────
1 │ 255.0 0.0 0.0 255.0 0.0 0.0 0.0 0.0 100.0
2 │ 255.0 0.0 0.0 255.0 0.0 0.0 0.0 100.0 300.0
3 │ 0.0 255.0 0.0 0.0 255.0 0.0 0.0 300.0 1000.0

julia> topo = makecpt(cmap=(:red, :blue, :green, :yellow), range= [0.0, 0.01, 0.05, 0.1, 0.2]) #make colorbar other options: color=:polar
Extract of a GMTcpt exposed as a GMTdataset for display. Colors converted to [0-255]
Model: rgb
Color depth: 24
4×9 GMTdataset{Float64, 2}
Row │ r1 g1 b1 r2 g2 b2 alpha z1 z2
│ Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64
─────┼─────────────────────────────────────────────────────────────────────────────────
1 │ 255.0 0.0 0.0 255.0 0.0 0.0 0.0 0.0 0.01
2 │ 255.0 0.0 0.0 255.0 0.0 0.0 0.0 0.01 0.05
3 │ 0.0 0.0 255.0 0.0 0.0 255.0 0.0 0.05 0.1
4 │ 255.0 255.0 0.0 255.0 255.0 0.0 0.0 0.1 0.2

@joa-quim
Copy link
Member

Had a very quick look (need to go out) and yes, there seems to be some error. Try

C = makecpt(cmap=(:red,:green,:blue), range="0,100,300,1000", no_bg=true)
imshow(C)

Note that the GMT.jl location is not that anymore. Type @? makecpt to see the new docs.

(I'll come back when I find what the first form is not working well)

@liming-he
Copy link
Author

Thanks for the quick response. It is something relating to the non-linear scale.

@joa-quim
Copy link
Member

Indeed, the behavior depends on the numbers, which is not right. It really looks a bug upstream (GMT binary)

# good

julia> makecpt(cmap=(:red,:green,:blue), range=[0 100 200 450])
Extract of a GMTcpt exposed as a GMTdataset for display. Colors converted to [0-255]
Model: rgb
Color depth: 24
3×9 GMTdataset{Float64, 2}
 Row │      r1       g1       b1       r2       g2       b2    alpha       z1       z2
     │ Float64  Float64  Float64  Float64  Float64  Float64  Float64  Float64  Float64
─────┼─────────────────────────────────────────────────────────────────────────────────
   1 │   255.0      0.0      0.0    255.0      0.0      0.0      0.0      0.0    100.0
   2 │     0.0    255.0      0.0      0.0    255.0      0.0      0.0    100.0    200.0
   3 │     0.0      0.0    255.0      0.0      0.0    255.0      0.0    200.0    450.0

# broken

julia> makecpt(cmap=(:red,:green,:blue), range=[0 100 200 451])
Extract of a GMTcpt exposed as a GMTdataset for display. Colors converted to [0-255]
Model: rgb
Color depth: 24
3×9 GMTdataset{Float64, 2}
 Row │      r1       g1       b1       r2       g2       b2    alpha       z1       z2
     │ Float64  Float64  Float64  Float64  Float64  Float64  Float64  Float64  Float64
─────┼─────────────────────────────────────────────────────────────────────────────────
   1 │   255.0      0.0      0.0    255.0      0.0      0.0      0.0      0.0    100.0
   2 │   255.0      0.0      0.0    255.0      0.0      0.0      0.0    100.0    200.0
   3 │     0.0      0.0    255.0      0.0      0.0    255.0      0.0    200.0    451.0

@liming-he
Copy link
Author

Thanks!

@joa-quim
Copy link
Member

For reference, issue GenericMappingTools/gmt#7558

@liming-he
Copy link
Author

Thanks for tracking the error.

@joa-quim
Copy link
Member

Fixed in #1200

@liming-he
Copy link
Author

thanks!

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

No branches or pull requests

2 participants