Questions tagged [matplotlib]
Matplotlib is a plotting library for Python which may be used interactively or embedded in stand-alone GUIs. Its compact "pyplot" interface is similar to the plotting functions of MATLAB®.
65,200
questions
1
vote
0
answers
10
views
how to set legend to a matplolib Axes in a subfigure plot
I am trying to plot the decision boundary of an SVM classifier using iris dataset. The class label doesn't appear on the legend although I set label=y.
Code:
import matplotlib.pyplot as plt
from ...
0
votes
0
answers
8
views
Regression with multidimentional target variable
I am trying to get a graphic representation of my regression model.
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
import pandas as pd
coord_u = ...
1
vote
0
answers
6
views
How to make a gif in matplotlib by changing the color
I want to make gif which the color of one part of the plot is changing. The plot includes two lines and I am filling the area between the curves by colors. This is the plot:
This code makes this plot:...
2
votes
1
answer
31
views
What is the reasoning for the step size?
I am trying to visualise a chess board in python, I have found this code online in order to be able to do so and I am trying to understand how it works. I have a rough idea of how majority of it ...
0
votes
0
answers
7
views
How to create density plots in same figure with two different x-axis?
So far this is what I've got:
for feature in scaled_features:
ax1 = axs[index]
ax2 = ax1.twinx()
sns.kdeplot(
boston_winsorized[feature],
ax=ax1,
...
-1
votes
1
answer
15
views
how to fix matplotlip invalid syntax error?
i'm trying to run this simple code but keep facing with this error.
i've downloaded everything and searched everywhere but still don't know how to handle this.
from matplotlib import pyplot as plt
...
0
votes
0
answers
4
views
python shell control+c disabled after plt.show()
I am running a local python shell in my mac terminal. Normally, when I press control+c, the current line is terminated, as expected in a terminal. However, after executing plt.show() and closing the ...
0
votes
0
answers
11
views
Options next to graph / plot
This is how it looks now:
current application
This is what I want:
what i want
I am looking for ways to directly implement options next to my graph. When I select an option, the option should be ...
0
votes
0
answers
5
views
How to embed matplotlib plot PyQt5 QGroupBox
I need to embed a plot into the PyQt widget. I can open the txt file with QFileDialog and plot the data separately, but I need to embed the figure into the initial solution group box. Here is the UI ...
0
votes
0
answers
21
views
How to make Hebrew RTL in matplotlib X axis?
I've been trying to plot grouped data and so far all goes well. However, I plot along the X axis with Hebrew text and it comes out Left-To-Right instead of Right-To-Left which makes it really ...
0
votes
1
answer
17
views
Save Matplotlib subplot as PDF using PyFPDF
I am trying to create two figures with two plots in each figure and then create a PDF file with one of the figures. I want to choose which figure will be saved in the PDF file.
I have this simple code....
1
vote
0
answers
18
views
Plot surface where Z depends on a vector of X and Y
I'm currently working on a small python script which can be used to interpolate points with a radial basis function approach. Therefore I would like to plot a surface where the Z value is calculated ...
0
votes
1
answer
14
views
VsCode matplotlib doesnt show figure window
import cv2
import matplotlib.pyplot as plt
import numpy as np
img = cv2.imread("Desktop\sudoku.jpg", 0)
img = np.float32(img)
plt.figure()
plt.plot()
plt.imshow(img), plt.axis("off&...
0
votes
1
answer
24
views
python Matplotlib getting stuck at graph and not running the rest of the code
The program gets stuck at the graph even though i use plt.show(block=False). I want to be able to close the graph and after x amount of time and plot something else but it doesn't work.
Sorry about ...
-3
votes
0
answers
28
views
Merging two 2D plots and try to get 3D view [closed]
I am trying to plot two 2D grouped bar plots on multiple axis with shared y-axis
Something like this (sorry for poor drawing skills)
Plots which i want to merge and share common y-axis
somewhat close ...
0
votes
0
answers
18
views
Matplotlib - Scientific notations overlap on multiple y-axis graph
I'm plotting a graph with 3 y-axis, and two of them have scietific notations. However, they overlap on the top-right of the graph. I'd like to have them separated, and if possible on top of their axis....
-2
votes
0
answers
8
views
how to plot the CDF diffrence in seaborn or matplotlib
I can plot the two cumulative distribution like thisenter image description here,but I wanna plot the difference btween like this picture.enter image description here,how can I do? thx
1
vote
1
answer
25
views
data highly skewed and values range is too large
i'am trying to rescale and normalize my dataset
my data is highly skewed and also the values range is too large which affecting my models performance
i've tried using robustscaler() and ...
1
vote
1
answer
10
views
set_axisbelow() not moving secondary axis
I currently have some code to generate a figure with two different y axes, ax and ax2. I would like to have ax2 and its associated plot behind ax, but I have tried doing this using set_axisbelow(True),...
-2
votes
1
answer
44
views
How can I draw reflections of a ray of light inside an ellipse using Python
Basically I want an image like this:
https://www.researchgate.net/profile/Wei-Chi-Yang-2/publication/343820209/figure/fig3/AS:927712428445696@1598195287061/Reflection-points-inside-an-ellipse-with-...
0
votes
0
answers
11
views
How to plot spatial time-series data after applying KMeans clustering?
I am trying to regionalize time-series precipitation data using EOF to remove noise in data, I have picked 5 principal components to be applied with KMeans in order to further see the regions more ...
0
votes
2
answers
19
views
Changing colours crossing zero pyplot Python
I want to code a Pyplot graph where it changes colors below the negative mark. I have conditions stated at the Color Conditions section. how would i be able to get this to work?
import pandas as pd
...
0
votes
1
answer
20
views
How to generate 2-yaxis graphs on a panel data per id?
I have a dataset, df that looks like this:
Date
Code
City
State
Quantity x
Quantity y
Population
Cases
Deaths
2019-01
10001
Los Angeles
CA
445
0
0
2019-01
10002
Sacramento
CA
4450
556
0
0
2020-...
-2
votes
0
answers
11
views
too many indices for array LOGISTIC REGRESSION GRAPHIC
I was trying to execute a graphic for Logistic regression with the following code:
h = 0.02
x_min , x_max = X_tiempo_IGPA[:,0].min()-0.5, X_tiempo_IGPA[:,0].max()+0.5
y_min , y_max = X_tiempo_IGPA[:,1]...
-1
votes
0
answers
30
views
Angle between a zero and non zero vector [closed]
I am trying to find angle between the horizontal zero vector red line. It is 1d array of 0 elements with total element 945(length 945). The black line is also an array of 945 elements with the minimum ...
1
vote
1
answer
24
views
adding legend to a subplot matplotlib
I have the following dataframe (simplified for security reasons):
sc =[[-2.3626099835364505, 2.34577702722125, 'A'], [-2.0075911304000322, 2.3676265784278554, 'A'], [-2.3309505510650244, 2....
0
votes
0
answers
13
views
I wrote a function which plots boxplot on top of a distplot using subplots. Now, using this function, I want to add the output as subplot in a grid
def UnivariatePlots(dFrame,column):
fig,(ax_box,ax_dist)= plt.subplots(2,1, sharex=True,figsize=(6,6));
sns.boxplot(x=dFrame[column],ax=ax_box,palette=sns.color_palette("deep"));
...
1
vote
2
answers
24
views
Can matplotlib plot decreasing arrays?
I am processing some data collected in a driving simulator, and I needed to plot the velocity against the location. I managed to convert the velocity and location values into 2 numpy arrays. Due to ...
0
votes
0
answers
16
views
Plotting a graph using specific row from a CSV File [duplicate]
I am very new to python and I am practicing using data from a CSV file to plot a graph.
The CSV file contains COVID-19 Data, the columns are:
Country, Total Cases, Total Deaths, Population, etc
What ...
0
votes
2
answers
31
views
While using WordCloud for Python, why is the frequency of the letter "S" considered in the cloud?
I'm getting to know the WordCloud package for Python and I'm testing it with the Moby Dick Text from NLTK. A snippet of this is as follows:
Snippet of my example string
As you can see from the ...
0
votes
1
answer
28
views
Matplotlib - Delete lines from a 3d quiver plot
I would like to graphically represent the time trend of a three-dimensional reference frame using Matplotlib and the quiver function. In an event, I simulated the data representing the reference frame ...
0
votes
0
answers
16
views
Matplotlib plot in a multiprocessing process does not show
Surprisingly, I did not find a question reproducing my issue. The code snippet below does not show any figure, why is this the case and how can I get the figure to appear?
import multiprocessing as mp
...
-2
votes
0
answers
21
views
how to eliminate Tkinter default app icon?
How can I get rid of the icon in the following image on Tkinter, it also appears on message boxes.
Thanks Icon!
1
vote
0
answers
35
views
How to plot a graph using matplotlib on Tkinter using a dataframe from pandas?
from openpyxl import load_workbook
from tkinter import *
import tkinter as tk
from tkinter import ttk
from tkinter import filedialog as fd
import pandas as pd
import seaborn as sns
import matplotlib
...
0
votes
0
answers
15
views
matplotlib blitting (animated plot) can't resize figure
I have an animated line using the example given on the matplotlib site:
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 2 * np.pi, 100)
fig, ax = plt.subplots()
(ln,) = ax....
-1
votes
0
answers
19
views
R: Interactive density plots [duplicate]
Say we have a dataframe composed by two columns, i.e. date and avg_price.
Instead of creating multiple density plots for any specific date range (until now I'm creating them using geom_density on ...
1
vote
1
answer
32
views
How to fill the logarithmic spiral with color
I have written a snippet to draw a logarithmic spiral, now the curves drawing is done, but for the color filling part, I'm not familiar with how to fill it (part between the two curves, and part ...
0
votes
0
answers
20
views
How can I make the dots move only 1 unit with every timestep and stop them from going through walls?
def move(self, workers):
while True:
self.row += random.randint(-1,1)
self.col += random.randint(-1,1)
if self.row >= 24:
self.row = 23
...
0
votes
0
answers
14
views
Python, Turtle - File "<string>", line 12, in forward turtle.Terminator + Matplot lib code gets stuck after the graph is plot
Hi there I have written a program in Python 3.10 and i am using the Libraries Tuple and Matplotlib.pyplot as well as time.
I have 4 different classes: Polygon, Square(Polygon) - Child Class, Shape ...
1
vote
1
answer
18
views
Pandas groupby index.month_name
Code
def plot_data_by_month(data, x, y) :
data_by_month = data[data[y] > 0].groupby(data[data[y] > 0].index.month_name())[y].mean()
ax = data_by_month.plot(figsize=(15, 10))
ax....
0
votes
0
answers
15
views
Identify and mask lakes
I have a question, I can mask out the oceans in the interpolation but not the lakes. Does anyone have an approach?
I have taken the masking of the oceans from: https://www.earthinversion.com/...
0
votes
1
answer
24
views
Plot on secondary yaxis not appearing in Python
I am currently trying to plot two sets of data on the same figure, sharing the same x axis but with distinct y axes. However, when I plot this, only the data from axis y1 shows up. how can i ensure ...
0
votes
0
answers
34
views
How do I check if my (x,y) are gaussian sampled?
I want to get (x,y) of 100 particles (x and y being initial conditions) sampled from a 2D gaussian where the 2-D gaussian is a product of two 1-D Gaussians so that (x,y) corresponds to a point on the ...
0
votes
0
answers
10
views
Is there a parameter that makes the line thicker and the tooltip more sensitive -> folium
I have the following map:
When hovering over a red line text appears. It is however hard to do. Is there a way to make the tooltip more sensitive so it shows up faster/easier? The polylines are ...
-1
votes
0
answers
14
views
plot a dataframe with reference to a column
I have a datframe as follows -
Time val1 val2 val3
1 0 1 1
2 0 0 1
3 1 1 1
I want to plot all the columns individually versus the Time column as subplots.
...
1
vote
1
answer
24
views
Add constant x, y , z lines into matplotlib 3D scatter plot in Python
I want to add constant x, y, z lines into a matplotlib 3D scatter plot in Python which extended from this limit point, may I know how could I do so?
x_limit = [-0.5] y_limit = [151] z_limit = [1090]
...
0
votes
1
answer
25
views
Can you help me out with line colors in plot
I want to change the color of the line but I have no idea how I should code.
import numpy as np
from sympy import *
import sympy as sp
t=sp.symbols('t')
y=sp.Function('y')
overdamped = Eq(10*y(t)....
-1
votes
0
answers
24
views
I am having trouble in some questions can anyone please help me [closed]
Add two optional command-line arguments to shrimpBase.py. These arguments are defined as follows:
a. The initial population of shrimp as an integer (default = 15)
b. A Y/N option as a string for ...
0
votes
0
answers
13
views
Visualize Output from collections.Counter() in descending order but get <BarContainer object of 207576 artists>
I am trying to visualize the output from
%matplotlib inline
out = collections.Counter(x)
plt.bar(out.keys(), out.values())
but I get only the following without the plot
<BarContainer object of ...
0
votes
1
answer
31
views
Partially filled circles in matplotlib scatter plot
I am currently trying to plot a partially filled circle in the matplotlib scatter plot.
The marker fill styles on the official documentation offers only half-filled or empty circles.
What I want is ...