Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
1 answer
51 views

Value Error can only convert an array of size 1 to a Python scalar

I want to plot a heatmap centered around a value of 1 showing the expression of genes corresponding to cell lines using this as code: import pandas as pd import numpy as np import matplotlib.pyplot as ...
Deichgraf's user avatar
2 votes
2 answers
54 views

How to save a matplotlib figure with automatic height to pdf

I have the following problem: I want to save a figure with a specific width, but auto-determine its height. Let's look at an example: import matplotlib.pyplot as plt import numpy as np fig,ax=plt....
Simon Schey's user avatar
4 votes
2 answers
161 views

Is there a way to detect a hump in a linear data?

I have a set of x and y data. When plotted, the data is linear except for a particular section where the data deviates from a straight line, something like a hump. My target is to develop a procedure ...
Luks's user avatar
  • 41
0 votes
1 answer
77 views

Circular Import and Initialization Error when importing matplotlib with numpy

I have already attempted uninstalling and reinstalling matplotlib I'm encountering the following errors when I attempt to import matplotlib import numpy as np import matplotlib Returns: ImportError: ...
HowCanDoesCK's user avatar
0 votes
0 answers
45 views

Implementation of the SIRD model in Python

I'm working on a project for my class where I'm trying to implement the SIRD model with the vaccinated population. I wrote my code based on my equations, but something seems wrong with my graph. The ...
arthika 's user avatar
3 votes
1 answer
133 views

Accessing the end of of a file being written while live plotting of high speed datastream

My question refers to the great answer of the following question: Real time data plotting from a high throughput source As the gen.py code of this answer was growing fast, I wrote own version gen_own....
ecjb's user avatar
  • 5,391
1 vote
2 answers
63 views

Gaps in a `matplotlib` plot of categorical data

When I have numerical data, say index by some kind of time, it is straightforward to plot gaps in the data. For instance, if I have values at times 1, 2, 3, 5, 6, 7, I can set an np.nan at time 4 to ...
Dave's user avatar
  • 346
-2 votes
1 answer
42 views

How to limit vertical line range in negative number field

I drew a linear graph below y=0, and now I want the vertical lines x=0.52 and x=0.75 reach the graph, not crossing the whole xy field. import numpy as np import matplotlib.pyplot as plt %matplotlib ...
Lihime's user avatar
  • 7
1 vote
2 answers
50 views

How to control plot size whith different legend size matplotlib

I want to have 2 plots of the same size. The size of the figure is not as important. The only change I am making is to the length of the labels. (In reallity I have 2 related data sets ) A long label ...
Frank Musterman's user avatar
0 votes
0 answers
46 views

Numpy: What should I be considering when deciding where to put batch dimensions in my class functions to leverage vectorization?

I am writing some code using numpy that involves vectors, matrices, and functions from vectors to matrices. In particular, I am interested in running these functions over many vectors and many ...
Minty's user avatar
  • 53
0 votes
1 answer
68 views

How do I turn-off this horizontal line in the FFT plot [duplicate]

I am trying to show the trend in observation data and the corresponding fft . A horizontal line keeps appearing in the fft, part that I do not need to show in the chart. I give a MWE (pseudo data) ...
Amina Umar's user avatar
0 votes
2 answers
86 views

Installing Numpy, Pandas etc. packages on PyCharm Community

I am trying to install Pandas, Numpy, Matplotlib on PyCharm Community. However, it says you have to upgrade to PyCharm Pro to access these? So, can anybody please explain whether I have to get the ...
user28054406's user avatar
-2 votes
2 answers
65 views

MemoryError in creating large numpy array

My objective is to plot a histogram given values and counts. hist only takes an array of data as input. I have tried to recreat data using np.repeat, but this gives MemoryError: Unable to allocate 15....
pkj's user avatar
  • 781
0 votes
0 answers
59 views

Dividing polygon into almost even triangles via growth algorithm (Python)

I have this code thats taking in the vertices of a given polygon, calculating its area, dividing it by n. After that, it takes one point of the polygon and "draws" a triangle with 2 ...
Gacki's user avatar
  • 1
0 votes
0 answers
31 views

Indent problem with Clicker in Matplotlib

I have taught myself enough Python/PyQt6/Qt Designer in Visual Studio Code to create a program that inverts a positive RGB image into a true negative. The program plots the positive inputs against the ...
user27792357's user avatar
0 votes
1 answer
63 views

fill_between plot fails on specific index value combo for a pands time-series

I try to do a plot and observe a strange error: import pandas as pd import matplotlib.pyplot as plt idx = pd.TimedeltaIndex(['0 days 00:00:00', '0 days 06:00:00', '0 days 12:00:00', '0 days 18:00:00']...
CodeNStuff's user avatar
0 votes
0 answers
47 views

SciPy Stats Library .fit() Command Issues Generating Fit With Imported File

I have an Excel file I have imported into a Pandas DataFrame. The file has four variables and we are supposed to run normality tests (Shapiro-Wilk, D'Agostino's, Anderson-Darling) for the data and ...
Jason Word's user avatar
0 votes
1 answer
54 views

Slice list of 2D points for plotting with matplotlib

I've got a list of two-dimensional points represented in a numpy style array: lines = np.array([ [[1,1], [2,3]], # line 1 (x,y) -> (x,y) [[-1,1], [-2,2]], # line 2 (x,y) -> (x,y) ...
mefiX's user avatar
  • 1,307
1 vote
1 answer
62 views

How can I plot printed data

I'm doing homework to generate a curved graph for my python course, and since it's my first time learning python, I have difficulties making an even simple code. I use Jupyter Handbook for my learning....
Lihime's user avatar
  • 7
3 votes
2 answers
210 views

Capturing Matplotlib coordinates with mouse clicks using ipywidgets in Jupyter Notebook

Short question I want to capture coordinates by clicking different locations with a mouse on a Matplotlib figure inside a Jupyter Notebook. I want to use ipywidgets without using any Matplotlib magic ...
divenex's user avatar
  • 17.1k
0 votes
1 answer
65 views

Gamma function fitting OptimizeWarning: Covariance of the parameters could not be estimated in Python

I am trying to fit functions to histograms using curve_fit from scipy, however a warning occurs when running the program: import numpy as np import matplotlib.pyplot as plt from scipy.optimize import ...
Ani Nalbandyan's user avatar
3 votes
1 answer
46 views

Values over bars in barplot not centered

I have the following code, which produces a plot, that plots two dictionaries next to each other, where the y-axis are the days and the y-axis the relative costs. Since the plot is pretty bloated, i ...
manofthousandnames's user avatar
0 votes
1 answer
446 views

Matplotlib's plt.show() throwing "ValueError: object __array__ method not producing an array"

I'm trying to run the following simple lines of Python code: import numpy as np import matplotlib.pyplot as plt x = np.array([1, 2, 3]) y = np.array([4, 5, 6]) plt.plot(x, y) plt.show() But 'm ...
TheTomer's user avatar
  • 381
0 votes
0 answers
42 views

How to bold only e.g. the first, second, and second-to-last horizontal lines in a matplotlib table?

I'm working with matplotlib to create a table, and I need to bold specific horizontal lines. Here's my current code: np_table = table1(data) fig, ax = plt.subplots(figsize=(6, 2.5)) ax.axis('off') ...
Jelly Bean's user avatar
0 votes
1 answer
41 views

Python skimage: Turning grayscale image array into float makes the image use color instead of grayscale

When using the skimage.io module in python to read an image in grayscale, it works as intended. However, doing anything to the numpy array holding the values which results in them changing to float ...
Max Goodman's user avatar
0 votes
0 answers
37 views

I cannot animate the scatter plot in matplotlib. Every frame is the repeat of the first frame data plot

I am writing a python script to animate data from a list of .xyz files using matplotlib. However, the animation is actually static because each frame of the animation is displaying the data from the ...
lokit khemka's user avatar
0 votes
1 answer
52 views

How to fix "x and y must have same first dimension, but have shapes (192,) and (1,)" error?

I can't figure out why the shape of y is (1,). I thought since the return of my function is being calculated with the same thing I'm plotting on the x axis that they would have the same shape. Any ...
Jack6647's user avatar
1 vote
0 answers
84 views

Can't import matplotlib in jupyter notebook

I have Python 3.9 in a virtual environment on my work PC. When I start the virtual environment with source ./python3.9_venv/bin/activate and then launch a python terminal with the command python3 , I ...
K.defaoite's user avatar
0 votes
0 answers
32 views

VSCode not resolving installed libraries [duplicate]

VSCode throws errors for both Matplotlib and numpy. Both are installed, I'm running the correct version of Python, and running the code in IDLE works fine. Python is not running virtual environment, ...
viridian green's user avatar
1 vote
0 answers
54 views

How to find the value of x given a y in Seaborn lineplot [duplicate]

As the title says, I want to obtain the value of x given a y in a Seaborn lineplot. I have the following plot: sns.lineplot(y=outlier_percent, x=np.linspace(0.001, 3, 50)) Where outlier_percent is ...
defconand's user avatar
0 votes
1 answer
73 views

How to properly shear a line in a 2D image using interpolation in Python?

I'm trying to apply a shearing transformation to a simple 2D line filter (represented as a binary image) using interpolation methods in Python. However, the resulting image after applying the shear ...
tag's user avatar
  • 459
-1 votes
1 answer
82 views

How to correctly extract white pixels from binary images and display them correctly on the plotlib?

This is a binary image, I want to calculate the distance between two edges of the pixel, then display it on a drawing board. I handle it when it does not have branches, but when it has branches like ...
Abukeram's user avatar
0 votes
1 answer
81 views

Transfer numpy array coordinates to matplotlib coordinates

I do not know whether I'm doing a thinking mistake but I struggle a bit with the transfer from numpy array coordinates to matplotlib coordinates. As an example I underpin piece of sources of the ...
stschn's user avatar
  • 147
2 votes
1 answer
49 views

Exponential plot in python is a curve with multiple inflection points instead of exponential

I am trying to draw a simple exponential in python. When using the code below, everything works fine and the exponential is shown import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as ...
meJustAndrew's user avatar
  • 6,583
1 vote
1 answer
51 views

Plot annotations clipped by plt.savefig

I am plotting sunrise and sunset times using code adapted from the matplotlib colormap examples The code is below: import datetime import numpy as np import matplotlib.pyplot as plt # Define month/...
PetGriffin's user avatar
3 votes
1 answer
76 views

wordcloud with 2 background colors

I generated this on wordcloud.com using one of the "themes". I'd like to be able to do this with the python wordcloud library, but so far all I can achieve is a single background color (so ...
nettie's user avatar
  • 692
0 votes
0 answers
119 views

Coefficients for inverse polynomial fit in Python

I am using SciPy's optimize.curve_fit to get polynomial coefficients for an implicit function, and that was successful. I now have y(x). I need x(y). If I instead do a curve_fit for y, x (as opposed ...
kriegersan's user avatar
0 votes
2 answers
72 views

How to cplot() a conditional function

I want to plot this function defined on complex numbers: if floor(Re(z))%2==0, f(z)=z else f(z)=sin(z) I tried to code this: import cplot import math import numpy as np def f(z): if math.floor(np....
pie's user avatar
  • 127
1 vote
1 answer
45 views

Iteration of a graph approximation

The code below runs a model based on a graph generated by the solution to a system of differential equations and shows one with random 5% error added to the points. How would I iterate this process (...
user1134699's user avatar
0 votes
1 answer
67 views

Why am I seeing two lines within each subplot?

I am currently working on graphing a set of signals' Fourier Transforms. The issue that I am currently facing is that there seems to be a flat line in every single subplot, whose origins I am unsure ...
Riderdie's user avatar
0 votes
1 answer
69 views

Change y axis scaling on a Seaborn Heatmap

I am at the final stage of displaying a heatmap within a facetgrid. When I am presenting the data, some of the index values may or may not be present for the row / column combination. I would like to ...
sxs's user avatar
  • 59
0 votes
1 answer
55 views

Plotting arrows of arctan2 argument over a map in Python

I plot a matrix 'diff' (quadratique sum of the input matrix diff_X and diff_Y) as a colored map using imshow and I would like to display arrows showing the corresponding angle arctan2(diff_Y/diff_X) ...
A_Mlt's user avatar
  • 1
0 votes
0 answers
43 views

Calculating the ARE of parameters

I have the following code: import numpy as np import matplotlib.pyplot as plt from scipy import integrate, optimize import random def dose(t, y, b, s, c, p, d): target, infectious, virus = y ...
user1134699's user avatar
1 vote
2 answers
55 views

sharex and imshow do not produce plots of the same width

Context: I have the x,y and x,z projection of an image. I want the two images to be stacked vertically sharing the same width. My trial: I tried the following: import numpy as np import matplotlib....
Antonio Ragagnin's user avatar
0 votes
1 answer
55 views

Computing and Visualizing Linear Trends in Ocean Temperature Data

I have a dataset containing ocean temperature values for the time period 1950-2022, covering the entire globe. My goal is to calculate the linear trend for each surface grid box and visualize the ...
faeze bh's user avatar
0 votes
1 answer
88 views

Plot a path in a very large 2D matrix using Matplotlib

I want to plot a path in a very large (e.g. 500K x 500K) 2D matrix. My current approach is creating an uint8 np array (for space-saving reasons, as I only have 4 possible values) and plotting it with ...
Quim's user avatar
  • 21
0 votes
2 answers
264 views

Plotting a chirp square signal in python

Wikipedia definition: A chirp is a signal in which the frequency increases (up-chirp) or decreases (down-chirp) with time. In some sources, the term chirp is used interchangeably with sweep signal. I ...
DrCoolZic's user avatar
0 votes
1 answer
50 views

Three array scatter plot using Numpy and Matplotlib

import matplotlib.pyplot as plt x =[24,73,94,8,26,80,89,23,7,50] y =[52,98,48,39,50,84,76,96,76,9] z=[14,56,79,21,42,67,5,55,27,91,10] plt.scatter(x, y,z) # To show the plot plt.show() I ...
KAVSHEKAA V CSBS's user avatar
0 votes
1 answer
45 views

Average of Sampled Data at Different Sampling Points

I need to plot the average of different trails of my sampled data y. The difficult part is that the corresponding sample points x do not coincide. However, x can only range from 0 to 1. The following ...
Isotope's user avatar
  • 143
0 votes
0 answers
44 views

Does the Intensity of color in OpenCV image matter?

Here is a simple code which puts a text value onto a black frame and displays it: frame = np.zeros((50,200,3)) org=(0,45) font=cv2.FONT_HERSHEY_SIMPLEX fontScale=1 fontColor=(1,0,0) ##rgb out_img =...
Allohvk's user avatar
  • 1,286

1
2 3 4 5
134