JuliaPlots / Plots.jl

Powerful convenience for Julia visualizations and data analysis
https://docs.juliaplots.org
Other
1.84k stars 355 forks source link

GR colormaps #225

Closed tbreloff closed 8 years ago

tbreloff commented 8 years ago

@jheinen It seems like colormaps in GR are hardcoded? Is there a way that I can override the default maps with custom ones? I'm working on plotting images, and it's not taking my grayscale colormap:

tmp

tbreloff commented 8 years ago

Also BTW... this example is about 100x faster than PyPlot...

tbreloff commented 8 years ago

Also sort of related... it seems that heatmaps do interpolation by default... is it possible to turn on/off from within Plots?

tmp

tbreloff commented 8 years ago

One more thing I just noticed... I have yflip=true for the image above, and the colorbar is flipped as well. Can that maintain it's orientation separate from the y-axis?

tbreloff commented 8 years ago

I found another weird behavior... when I try to plot a scatter on top of the image (currently a heatmap linetype), it adds the scatter to the colorbar! Clearly the colorbar is being set to the "current axis" or something like that...

tmp

jheinen commented 8 years ago

@tbreloff : In GR there is a drawimage() routine which requires RGBA encodes 32-Bit integers. First of all, the gr.jl backend has to recognize the image object, then it must be converted into the RGBA representation.

Not a big deal, but, as I never used Image.jl before, give me some time and I'll add the missing code.

tbreloff commented 8 years ago

I'm not asking you to support images... I'm asking how to set the colormap. We get lots of functionality beyond just images if GR can use the Plots.ColorGradient (and images will work right away)

We can worry about native support for images another time.

On Saturday, May 7, 2016, Josef Heinen notifications@github.com wrote:

@tbreloff https://github.com/tbreloff : In GR there is a drawimage() routine which requires RGBA encodes 32-Bit integers. First of all, the gr.jl backend has to recognize the image object, then it must be converted into the RGBA representation.

Not a big deal, but, as I never used Image.jl before, give me some time and I'll add the missing code.

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/tbreloff/Plots.jl/issues/225#issuecomment-217630818

jheinen commented 8 years ago

In GR, there are 44 predefined colormaps, each containing 256 colors (color indexes 1000 - 1255).

using GR
y = 1.0
for cm in 0:43
  setcolormap(cm)
  cellarray(0, 1, y, y-0.02, 256, 1, collect(1000:1255))
  y -= 0.025
end

cm

COLORMAP_UNIFORM = 0
COLORMAP_TEMPERATURE = 1
COLORMAP_GRAYSCALE = 2
COLORMAP_GLOWING = 3
COLORMAP_RAINBOWLIKE = 4
COLORMAP_GEOLOGIC = 5
COLORMAP_GREENSCALE = 6
COLORMAP_CYANSCALE = 7
COLORMAP_BLUESCALE = 8
COLORMAP_MAGENTASCALE = 9
COLORMAP_REDSCALE = 10
COLORMAP_FLAME = 11
COLORMAP_BROWNSCALE = 12
COLORMAP_PILATUS = 13
COLORMAP_AUTUMN = 14
COLORMAP_BONE = 15
COLORMAP_COOL = 16
COLORMAP_COPPER = 17
COLORMAP_GRAY = 18
COLORMAP_HOT = 19
COLORMAP_HSV = 20
COLORMAP_JET = 21
COLORMAP_PINK = 22
COLORMAP_SPECTRAL = 23
COLORMAP_SPRING = 24
COLORMAP_SUMMER = 25
COLORMAP_WINTER = 26
COLORMAP_GIST_EARTH = 27
COLORMAP_GIST_HEAT = 28
COLORMAP_GIST_NCAR = 29
COLORMAP_GIST_RAINBOW = 30
COLORMAP_GIST_STERN = 31
COLORMAP_AFMHOT = 32
COLORMAP_BRG = 33
COLORMAP_BWR = 34
COLORMAP_COOLWARM = 35
COLORMAP_CMRMAP = 36
COLORMAP_CUBEHELIX = 37
COLORMAP_GNUPLOT = 38
COLORMAP_GNUPLOT2 = 39
COLORMAP_OCEAN = 40
COLORMAP_RAINBOW = 41
COLORMAP_SEISMIC = 42
COLORMAP_TERRAIN = 43

There is no limitation to define other colormaps ...

tbreloff commented 8 years ago

👍 Lots of nice options! Two questions:

By the way... I'm starting to use GR more and more... it's really nice (and fast!) I can't wait for it to be fully supported

jheinen commented 8 years ago

You can set (setcolorrep) and inquire (inqcolor) single color entries:

for ci in 1000:1255
   r = g = b = (ci - 1000) / 255.0
  setcolorrep(ci, r, g, b)
  rgb = inqcolor(ci)
  println(uint32(rgb))
end

May be I should provide a more convenient way (in GR).

jheinen commented 8 years ago

I tried some things in 95e6847, but the (retrieved 100) color values did not produce nice results. I must have missed something ...

if haskey(d, :color_palette)
  ci = 1000
  for cv in d[:color_palette]
    GR.setcolorrep(ci, cv.r, cv.g, cv.b)
    ci += 1
  end
end
tbreloff commented 8 years ago

No that's not right. If you want to push up what you have (with that section commented out) I can help fix it.

On Sun, May 8, 2016 at 5:03 AM, Josef Heinen notifications@github.com wrote:

I tried some things in 95e6847 https://github.com/tbreloff/Plots.jl/commit/95e6847cfd3f56b5f239073e50c35b8b802a42a2, but the (retrieved 100) color values did not produce nice results. I must have missed something ...

if haskey(d, :color_palette) ci = 1000 for cv in d[:color_palette] GR.setcolorrep(ci, cv.r, cv.g, cv.b) ci += 1 end end

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/tbreloff/Plots.jl/issues/225#issuecomment-217704658

tbreloff commented 8 years ago

It seems like there are 3 outstanding issues here:

tbreloff commented 8 years ago

I think this is all working now