How to change colors of a boxplot in octave? - octave

I want to plot 9 distributions using boxplot in Octave. In order to make it more readable, I expected to able to change the inner colour of boxes, or the blue line surrounding it.
Looking at the source code, I realize that colours are hardcoded.
A matlab solution would be1:
a = get(get(gca,'children'),'children'); % Get the handles of all the objects
t = get(a,'tag'); % List the names of all the objects
box1 = a(7); % The 7th object is the first box
set(box1, 'Color', 'g'); % Set the color of the first box to green
Is there a similar procedure for octave? Or any other hints?
thanks in advance,
alan

Actually you are almost there. The following works for me for a single boxplot:
b = boxplot(data);
c = get(gca,'children');
for i=1:size(c)
set(c(i), 'color', 'g');
end
The above snippet colors the whole boxplot green. You can set the color of the individual c(i)'s to your liking.

Related

SSRS: How to improve the presentation of labels on a pie diagram?

I have a circular diagram and I am using the keyword #PERCENT to present the percentages of the different categories. But sometimes the labels overlap.
enter image description here
I have tried different tag property settings but i can't fix it.
I have also tried to configure an expression, but it generates an error:
=IIf( Cint(#PERCENT) < 1 , "", #PERCENT )
How can I improve the presentation?
Thank you! in advance
There are a few things you can do.
To fix what you are already trying to do you need to change your expression to something like
= IIF(
SUM(Fields!Amount.Value) / SUM(Fields!Amount.Value, "DataSet1") <0.01,
0,
"#PERCENT"
)
The assumes the pie chart is based on a fields called Amount and your dataset is called DataSet1 .
Then you need to set the Format property of the datalabel to something like
0.00;(0.00);' '
It's the part after he last colon that is important here ;' ' means, show zero's as a space.
You could set the label position to Outside so tey are not as close togther
You could "Explode" the small slices into another pie or move the these slices away from the main pie by setting the CollectedStyle in the CustomAttributes property group
in the example below this says "any slices that are <=20% or the chart" move them into their own mini chart.
Look at the SmartLabels property group in the Chaer Series properties.
Hopefully with this info you will have enough to improve your chart.

How to generate un-similar color palettes?

I'm going to draw a bunch of areas on the map. Each area should be of different color, preferably clearly different from the others. Of course, as the number of areas grows, I'm ducked. But until then I wonder where I could find or how I could generate a set of, say 15 colors that are "vastly" apart.
The first few were easy, because I used the defaults from Bootstrap:
blue
yellow
red
green
pink
But I can't stop wondering if there's a trick, tool or algorithm for generating a next, deviating color.
Googling gave me ways to generate similar schemas or colors that go well together. That's not what I'm looking for, though. Also, I discovered that there's much, muuuuch more to colors than mixing RGB, so I feel like a total looser noob.
You should indeed use the hsl 360 degrees to generate a well spread color spectrum. To have something like that in typescript/js you could do:
const length = 15;
const colors = Array.from({ length }, (_, i) => `hsl(${360 / length * i}, 50%, 50%)`);
Here you can see a working example:
stack
Result:

manipulating ndarray dimension with function and adding new data to it

I'm using this to control the color scale on a fractal drawing program. I was wondering if there was a way to eliminate the r,g,b variable and insert the result right into the img ndarray? I have fiddled with adding a new dimension with np.expand_dims, but the shape turns into (5,5,1) instead of (5,5,3) like I need. reshaping it seems to be a nightmare.
import numpy as np
#img is an array of values to be converted into RGB from another process
img = np.arange(25)
img = np.reshape(img,(5,5))
#simplified example of original process
r = img*2
g = img*3
b = img*4
#creating new array to accomidate the higher dimension
img = np.array([r,g,b], dtype = np.uint8)
#no longer needed
del r,g,b
#rolling axis for PIL Image.fromarray compatibily
img = np.rollaxis(img,0,3)
img = np.rollaxis(img,0,2)
print(img)
img starts as a (5,5) array. That's one value for each of the 25 pixels.
The new array after joining the r,g,b arrays is (3,5,5).
The first rollaxis changes that into a (5,5,3) array.
np.stack([r,g,b], axis=2)
would have done the same.
The second rollaxis swaps the first two dimensions, in effect transposing the original image. (in fact both rollaxis could be replaced with one img.transpose().
Even when you use expand_dims you still make a new array (though it does share the databuffer with the original). But (5,5,1) still doesn't have space to store the 3 color values. The original has 25 values, the new image has 75. You have to make a new array in one way or the other.
To better understand the rollaxis part, I suggest playing with an array like
arr = np.arange(24).reshape(3,2,4)
different sizes in all 3 dimensions make it easier to see the changes in shape.

Individual Y axis domain in multiple charts in D3

I will create multiple charts from one CSV-file using D3. I want the the Y axis du update in each chart. Now the y axis is the same for all charts. It is set by the maximum value in the whole number1 column, and not for each chart created with d3.nest.
How can i make the Y axis fit to the number1 data in each chart?
What is wrong with the code? JSbin
This is my CSV-data:
name,year,number1,number2,number3
Superman,2003,227141296,214978953,212418250 <-- number1 should be max for Superman chart
Superman,2004,232769230,220606887,211301729
Superman,2005,192769230,220606887,211301729
Batman,2003,252873171,239836381,225174161 <-- number1 should be max for Batman chart
Batman,2004,286137492,262439880,243001175
Batman,2004,232769230,220606887,211301729
Spiderman,2006,809584667,279490239,248758932 <-- number1 is now max in every chart
Spiderman,2007,324081833,278022620,246734614
Spiderman,2008,294081833,278022620,246734614
I've bumped your bin to here. Essentially, I added three divs and svgs using the d3.selectAll.data(heroes).enter();pattern. I then used the forEach to add in the axis's and line to each div / svg by passing in each element of the array in the object you created. Note that for some reason, jsbin isn't appending the first of the svg elements.
The maxNumber values was then passed to the y-axis constructor inside the foreach loop as were the year / number1 (x/y) values. The x/y values were passed to a single line generator, instead of the three separate line functions, making things a bit tidier.
Anyhow, hope this helps.

I need a function to check each pixel then return the x and y for that pixel

I want to test each pixel in an image and check it's color if it is white then I must display
the corresponding (x,Y) for that pixel but I didn't find until now a function that help me
do something like that. So please if you have such function tell me.
thanks at all
If you are using matlab for image editting, the function for this purpose would be imread, i.e. if you have a MN image them imread would split it in a matrix of [MN*3], i.e. a 3 dimensional array representing RGB components of the image. Now if at a given X,Y coordinate, all the three i.e. Red, Green and Blue components have equal value, then that pixel is not color. If they have different values then it is coloured pixel. Using an if condition check and generate a new picture matrix accordingly. Display the new picture matrix.
I don't know if there is such a function. maybe in some deep graphics toolkit? it'll certainly not be part of a basic language framework (i.e. core stuff in objc or system in c#).
you might have to bite the bullet and just work your way through all of the pixels manually in o(n^2).
foreach horizontal pixel
foreach vertical pixel
if(pixel at (horizontal,vertical) is white)
return (horizontal, vertical)