matplotlib

Displaying a RGB image in float64

Displaying a RGB image in float64 Question: I have an image with data type uint8. I want to convert it to the data type float64 and display it. I expected to see the image as I displayed it with data type uint8. But the result is this: My original image is like this: Why is …

Total answers: 1

Change the shape of legend markers with geopandas.geodataframe.plot

Change the shape of legend markers with geopandas.geodataframe.plot Question: I like the convenience of the following syntax to make maps: import geopandas world = geopandas.read_file(geopandas.datasets.get_path(‘naturalearth_lowres’)) world.plot(column=’continent’,legend=True,legend_kwds = {‘loc’:’lower left’}) However, I am looking for a way to change the shape of markers that this produces. By default (with a non-continuous variable), geopandas (or matplotlib) produces …

Total answers: 1

How to Plot Columns of x and y Coordinates with the Third Column as Legend

How to Plot Columns of x and y Coordinates with the Third Column as Legend Question: Assuming i have a data frame with three columns: x : x coordinates – y : y coordinates – type : detrermining the type (there are only two) import pandas as pd import matplotlib.pyplot as plt data = {"x" …

Total answers: 2

Python – Plot multiple columns against time stamp with different xlabels

Python – Plot multiple columns against time stamp with different xlabels Question: My dataframe is 29-03-2023 18:08,2,Con,0 29-03-2023 18:08,2,Temp,27.2 29-03-2023 18:08,2,hum,44.4 29-03-2023 18:08,2,Con,0 29-03-2023 18:08,2,Temp,27.2 29-03-2023 18:08,2,hum,44.3 29-03-2023 18:08,2,Con,0 29-03-2023 18:08,2,Temp,27.2 29-03-2023 18:08,2,hum,44.4 29-03-2023 18:09,2,Con,0 29-03-2023 18:09,2,Temp,27.2 29-03-2023 18:09,2,hum,44.4 29-03-2023 18:09,3,Con,0 29-03-2023 18:09,3,Temp,27.2 29-03-2023 18:09,3,hum,44.4 I want to plot a graph for each sensor’s con, …

Total answers: 1

About "mirroing" a graph

About "mirroing" a graph Question: i would like to know how i can mirror a graph in order to, for example, transform an X axis (-200 -100 0 100 200) into (200 100 0 100 200). I tried to do it in this script: import numpy as np import matplotlib.pyplot as plt T=1400 Q=1000 R=1000 …

Total answers: 1

How to stop matplotlib from incorrectly adding lines at vertical asymptotes?

How to stop matplotlib from incorrectly adding lines at vertical asymptotes? Question: For functions that contain vertical asymptotes, y^2 = x^3/(2(3) – x) for example, matplotlib will add in vertical lines at the asymptotes which majorly throws off the expected graph. I am using plot_implicit() from sympy. I have tried setting the adaptive attribute to …

Total answers: 1

use numpy.ndarray in matplotlib title plot with format

use numpy.ndarray in matplotlib title plot with format Question: I am using Sara and matplotlib of some of work and I was wondering how could I use a class numpy.ndarray with specific format in the title of a plot I am doing. The variable type is: type(global_mean.data) <class ‘numpy.ndarray’> and value: global_mean.data array(0.12485412, dtype=float32) And …

Total answers: 2

Python – Two different bar charts next to each other

Python – Two different bar charts next to each other Question: I am using matplotlib to analyze my data. For this I created a dataframe with following structure: merge.set_index(‘index’, inplace=True) print(merge) username mentioned_user index matthiashauer 73 10 derya_tn 67 5 renatekuenast 36 9 ralf_stegner 35 73 mgrossebroemer 33 12 … … … katrinhelling 1 1 …

Total answers: 1

How to add the text to the side of the line using matplotlib?

How to add the text to the side of the line using matplotlib? Question: I have a code which generates the line using matplotlib. Below is the code import matplotlib.pyplot as plt plt.figure(1100) plt.plot(np.array([1,1]),np.array([0,3]),’k’,’LineWidth’,5) x = np.array([1,1]) y = np.array([0,3]) plt.text(x[-1], y[-1]+0.5, ‘(t)’, ha=’center’) plt.show() Below is the output of the above code I need …

Total answers: 1

How to use mplcursors with stacked bars in matplotlib

How to use mplcursors with stacked bars in matplotlib Question: I am trying to create a stacked bar with matplotlib and getting stuck of using mplcursors. When I run the program then it seems like all bars show the last data of the last person if I use (without [sel.index]): info.connect("add", lambda sel: sel.annotation.set_text(dict[nameList[i]][2])) If …

Total answers: 1