I have a single band image with dimensions (62, 62), that ranges from [0, 0.3]. For context it is the NDVI band, calculated by (NVI-Red) / (NVI+Red), where NVI is a band. Can more about it here: https://en.wikipedia.org/wiki/Normalized_difference_vegetation_index I display my image with cmap=RdYlGn to get: However, now I want to apply the cmap to ndvi and save it to
Tag: matplotlib
Remove the intersection between two curves
I’m having a curve (parabol) from 0 to 1 on both axes as follows: I generate another curve by moving the original curve along the x-axis and combine both to get the following graph: How can I remove the intersected section to have only the double bottoms pattern like this: The code I use for the graph: I’m doing a
Scikit Image load binary image and convert to binary matrix
I have created a numpy array shape(11 x 11) with all pixels 0 excluding one column filled with 1. The array was saved as a png image using matplotlib.imsave yielding the expected image – black background with a white line in the middle. When trying to reimport the saved png image skipy.imread and Pil.Image.Open yield an array of the form
adding legend to lineplot according to maplotlib’s axvspan
OK, I have this line plot of data trend over this period. Figure: But I want to add legend corresponding to each period (coloured) covereds, such that: 2021-03 to 2021-06 the green area bears the legend spring, 2021-06 to 2021-09 blue area is legend summer, and 2021-09 to 2021-12 (magenta) legend winter. Answer You can specify a label in the
Adding legend to heatmap in Python / Matplotlib with circles that compare total users, and colors that indicate ratio of abandonment in single graph
I found in SO an explanation to add a legend to this type of graph. However, it does not translate well with my data. I got my graph with circles and shades of colors to work. I do have the legend indicating what the shades of color mean in terms of ratio of users abandoning a chatbot at a given
how to turn dictionary of integers into a heat map using matplotlib
I am wondering how I can make a heatmap using matplotlib. I cant really explain it so ill just show you an example. here is an example grid it is stored in a dictionary like this I was wondering how I can convert this dictionary into a heat map using matplotlib. Answer Here’s a very barebones example: Note that I
How to set axis label format to scientific format in seaborn relplot with facets when axes are not shared
I am creating a facet plot with the seaborn library with: I would like ALL subplots to have scientific notation. Using Seaborn version 0.11.2 Answer Since the axes are not shared, the format can be set by iterating through each axes. This answer shows how to set the tick label format when x and y are shared. Tested in python
Plot don’t refresh when slider updated matplotlib
I can’t figure out why the plot don’t refresh when the slider is updated. I’m using Jupiter notebook and I choose the backend with ‘nbAgg’ parameter. Initialization code : There is a animation which lunch this function : The animation : Here the slider which stuck me : This below function don’t work as expected : Answer You can try
How to organise multiple stock data in pandas dataframe for plotting
I have over a hundred stocks (actually crypto but that does not matter) I wish to plot, all on the same line plot. I end up with a dataframe that looks like this: I don’t know how to make a line plot from this dataframe, I don’t even know if it is possible. Is there a way? Or is there
xticks and yticks issues while using imshow
I’ve a problem with fixing the xticks and yticks for the imshow plot. When I use the single plot for imshow then the extent works better (see first figure below). However, when I use to insert the coordinates of the local maxima on the imshow plot then the ticks have changed (second figure). Can anybody help me to fix the