Controlling Color Shades in Flot - flot

I have a bar chart where I need to limit the number of colors used, so that different bars may end up with the same color. For example, if the colors are limited to Red and Blue and there are 6 bars (each its own series), then show them as:
Red Blue Red Blue Red Blue
(This is NOT 2 series repeating at each x axis.)
I have done this by creating a variable with an array of colors:
var availableColors = ["Red", "Blue"];
then in the configuration I have set:
colors: availableColors,...
This only sort of works. The two colors do indeed repeat across all of the bars, but each time a color repeats in a new bar, it shows up in a different shade of that color. (I intentionally have not made "Grey" one of those colors, so no 50 Shades of jokes.)
How do I keep the colors fixed on each bar so that I don't get shades of each color?

How about this?
var availableColors = ["Red", "Blue", "Red", "Blue", "Red", "Blue"];
What happens with your array is the default behaviot of flot (see the documentation):
If there are more data series than colors, Flot will try to generate extra colors by lightening and darkening colors in the theme.
If the number of colors you need is variable, create the array dynamically in your script.

Related

SSRS: Is it possible change border color based on series color in tree chart?

We work with SSRS 2016.
I'm wondering is there a possibility to change a tree chart series border color according to color of series? E.g. if chart series color = "Red" then border color = "Blue".
Yes, we can operate colors based on series values using switch function if the values set is limited, like:
=switch(Fields!country.Value = "Europe","#black" ,
Fields!country.Value = "Asia", "#blue",
........, etc.
)
But if values are too many switch is not a solution.
Can you please advice whether it possible to implement expected conditional coloring?
Basically yes, but not the way you want to do it. Lets say your series color expression is the following:
=IIF(Fields!SeriesName.Value = "SeriesA", "Red", "Green")
For the border color you can not check for the color, but you can use the same expression again. Like this:
=IIF(Fields!SeriesName.Value = "SeriesA", "Blue", "Black")
This way your SeriesA color is Red and the border is Blue.

How does ncurses' init_color function translate to traditional rbg colors?

Sorry for the oddly worded title. I'd like to know how the ncurses init_color function maps it's input to colors. Essentially, most developers are used to colors being represented by red, green, and blue on a 0 - 255 scale, but init_color takes an int on a 0 - 1000 scale.
for example:
If I wanted to get the color (75, 0, 130) in ncurses, would I call init_color(COLOR_NAME, 300, 0, 520)?
short:
(n) * 1000 / 256
which is a little different from your numbers:
293 0 508
long: That of course assumes that the terminal description is written to match ncurses' documentation. But the assumption is from X/Open Curses:
The init_color() function redefines colour number color, on terminals that support the redefinition of colours, to have the red, green, and blue intensity components specified by red, green, and blue, respectively. Calling init_color() also changes all occurrences of the specified colour on the screen to the new definition.
The color_content() function identifies the intensity components of colour number color. It stores the red, green, and blue intensity components of this colour in the addresses pointed to by red, green, and blue, respectively.
For both functions, the color argument must be in the range from 0 to and including COLORS-1. Valid intensity values range from 0 (no intensity component) up to and including 1000 (maximum intensity in that component).

Create a false color palette and associate pixel values with it

I have raw pixel data (640x480 pixels) from an infrared camera which stand for a specific measured temperature. These pixel values have a 16 bit range from 0 to 65535.
I can display the pixel values as 8 bit greyscale, which works very well.
But now I want to display those pixels by using a false color palette.
I noticed 2 challenges here:
1.) Creating a false color palette. This means not just a simple RGB or HSV palette...I am thinking of a transition from black to yellow, to orange, to red and finally to purple
2.) Associating the pixel values to a color on my palette (e.g. 0 = black, 65535 = purple, but 31521 = ???)
Do you have an idea how I should approach this problem? I use Qt4 and Python (PyQt) but also I would be very happy if you just share the way for a solution.
One simple way would be to define colors at certain points in your range - as in your example, 0 is black, 65535 is purple, maybe 10000 is red, whatever you want to do. Set up a table with those key rgb values, and then simply interpolate between the rgb values of the key values above and below your input value to find the rgb color for any given value.
eg. if you're looking up the color for the value 1000, and your table has
value=0, color=(0,0,0)
value=5000, color=(255, 0, 255)
Then you would interpolate between these values to get the color (51, 0, 51)
The easiest method is as follows:
Cast your unsigned short to a QRgb type, and use that in the QColor constructor.
unsigned short my_temp=...;
QColor my_clr((QRgb)my_temp);
This will make your values the colors between black and cyan.

Set the color steps in the GnuPlot color bar

I would like to have a color bar divided into 5 colors. One color from 0 to 20, another until 40, and so on until 100.
What I have done so far is:
set palette maxcolors 5
But this doesn't set the boundries of each color in the colorbar
Do you have suggestions?
To avoid setting the boundaries manually, you're on the right track. What might help is to set the color bar's range:
set cbrange [0:100]
That way the palette will be divided into 5 colors just between 0 and 100, instead of having the limits determined by the data/function being plotted.

Gnuplot: controlling colours and ranges of "set palette."

I'm using gnuplot to make a colour-map. What I need is, when I set a palette I need to define the ranges and colours such that certain ranges have the same colour.
For example, say the third column of the data ranges from 100 to 150. I need 100 to 120 to be same colour, then 120 to 130 same colour. I tried doing it this way
set palette defined (100:120 "gray", 121:129 "blue", 130:150 "dark-gray")
But it gnuplot says this is invalid expression, specifically pointing at the " : ".
Is there any way around this?
check out set palette maxcolors. From the help page:
This option can also be used to separate levels of z=constant in discrete
steps, thus to emulate filled contours. Default value of 0 stays for
allocating all remaining entries in the terminal palette or for to use exact
mapping to RGB.
Also note that you should be able to do something like:
set palette defined ( 100 "gray", 120 "gray", 121 "blue", 129 "blue" )
but be careful -- the numbers 100, 120, 121, 129, etc don't correspond to the values on your colorbar unless you set cbrange [100:129] (for example).

Resources