I am trying to create a chart where I want to display sales as a bar and profits using colour. The bars will be used to inform the sales figures (taller bars mean higher sales). But at the same time, the bar will be used to inform the profits too using a colour. Higher profits mean darker shade of a colour, lower profits mean a lighter shade of the colour. I do not have any restrictions on using different colours so green, amber and red are also fine (in that case I need to define the ranges, eg., between 75 and 100: green, between 25 and 74.99: amber and anything below 25 as red).
How can I achieve this in Python, please?
Thank you.
Best wishes,
Manoj.
Related
I working with a .zarr file stored in a S3 bucket. I want to realize a use case of an index create with water coverage data which allows to follow evolution of the aquatic coverage. I display the file in a dataset and after clipping the file following the study area, i plot the data variable from a dataset with matplotlib as you can see here:
It represent the managua lake, in the blue color. Dark blue correspond to ocean, white to the pixels with no data and green to space with no water. My purpose is to count in this four categories: ocean, water, no data and no water the number of pixels according to this plot which you can see upper.
I already test to make this pixel_count = ((raster_managua >= 69) & (raster_managua <= 250)).sum() so make a sum of the categorie between 69 and 250 which correspond to water bu i have this error
TypeError: '>=' not supported between instances of 'FacetGrid' and 'int'
Can you help me ?
I am using imshow() to create pseudo-coloured maps of matrices of values (2d numpy arrays). Using clim argument one can set the range of values (below 1 and 6) to be represented within the colour scale (see below). This way for example all outliers (whether 7 or 7000000) will be yellow. This skews the perception of the image, as the reader doesn't know if this pixel is 6 or 700000.
Does anyone know of any way to colour all values outside of this range some other fixed colour of choice, for example, magenta?
The width of the grey area represents the frequency of the corresponding type. The maximum frequency 1.0 has a width of 0.1 as the starting types
I am trying to use python to draw a picture like this. It look more intuitive with the weight added to the related line in a shadow-like way. But I have no idea how to realise it.
I usually do stuff like this using matplotlib.pyplot.fill_between, with a low alpha (opacity of the shadow) and given the lower and upper bounds of the shaded area, which I'm assuming you could calculate from the frequency.
I have a (geographic) raster-image in RGB. I also have an external legend displaying the heights according to a certain color. In below figure, I have sampled this legend, hopefully revealing its RGB-characteristics. I have plotted these values to their actual height values on the X-axis.
Now, is it possible to directly derive height from the pixel's RGB-value? Ultimately, I'm looking for a simple formula which is able to translate my RGB values into one height value (e.g. H = aR + bG + c*B) Any hint or tips? Is it even possible at all?
In Matplotlib, I have several sets of points to fill in with different colours, one per set. Now, the number of sets varies, so I would like to make sure that that the same colour doesn't appear more than once in the same plot.
Right now I just do:
colors = itertools.cycle(['r','g','b','c','y','m'])
# ...
ax.plot(Xs_for_a_set, Ys_for_a_set, c=colors.next())
... but I am limited to that number of colors. From the documentation I don't get how to specify a random color in RGB...
You can specify the color as a hex value in a string.
color = '#eeefff'
Using this you essentially have access to all colors via RGB and can create as many colors as you need