Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
0 answers
10 views

Export Python charts excel with grid layout

I'm trying to write a Python script that generates a series of charts from Excel. The Excel file has the price of different cars on each day. Column 1 is the Date; Column 2 is price for Green cars; ...
Anthony Guida's user avatar
0 votes
1 answer
12 views

Seaborn boxplot add annotation labels for max values

I would like to show some values in a Seaborn box plot such as Total# observations, Mean, Mix/Max value for each box plot series. Is there a way to show these in the plot? import seaborn as sns import ...
John Honai's user avatar
1 vote
0 answers
9 views

How to use Matplotlib Renderer class in combination with custom OpenAI gym env

I'm currently working with the code of someone else to replicate some of their work (https://github.com/romanlee6/multi_LLM_comm). This code contains a custom OpenAI gym environment. I've managed to ...
Emma van Zoelen's user avatar
0 votes
0 answers
28 views

Return something from onclick?

I have a function that creates a chart with pandas & matplotlib. In the function there is an onclick handler that creates a table and then shows it with plt.show() upon click. When the entire ...
chocalaca's user avatar
  • 396
1 vote
1 answer
26 views

Is it possible to make a colour-blind friendly RGB option in "color" for ax.scatter?

I have scatter plot in which I have colour coded the scatter points according to the relative contribution of 3 factors. I use the red, green and blue channels to represent this. This works really ...
4sght's user avatar
  • 11
0 votes
1 answer
27 views

2D stacking and optimizing

I have big rectangle (pallet), and would like to stack boxes (smaller rectangles) in way to optimize space usage, currently my problem is I'm not sure how I can rotate the last row/column properly to ...
Bilal's user avatar
  • 3,797
1 vote
2 answers
27 views

modify markers and class labels jointplot

I need to replicate this plot in python. Specifically, I am unsure how to (1) change the marker shapes and (2) add class labels above each distribution, as shown in the example figure. Could you ...
Mik's user avatar
  • 11
0 votes
0 answers
19 views

Combine two axes in a single figure [duplicate]

I have two axes that were created separately in a figure and I would like to combine them into a single figure as a subplot. Specifically, I have a function create_plot(*args)that returns axis objects,...
kernel123's user avatar
1 vote
0 answers
85 views
+150

How to convert contourf values and plot to surface of 3d sphere

I am trying to use matplotlib contourf to generate a contour plot of temperature data. I would then like to map this data onto a 3d sphere. I am using vpython to render the image. The issue I have is ...
John's user avatar
  • 376
0 votes
0 answers
19 views

plot pre-computed mean and confidence intervals for two types of firms (python)

I want to plot two time-series lines with mean and CI each for low and high diversity firms (variable div_ind) throughout 8 calendar years (variable calyr). May I know how to do it? Online sources ...
Jaevapple's user avatar
0 votes
1 answer
29 views

Move Span center to click position not showing range when clicking in subplot with shown range

I have created a 2 plot subplot. Selecting the range in both subplots works fine. Clicking into the upper subplot (the zoomed plot) shifts both views fine, but when clicking in the lower (total view) ...
GvTT's user avatar
  • 13
0 votes
1 answer
29 views

How do I update a matplotlib plot in realtime and also have a REPL?

I am in a situation where I have a primitive REPL with some simple commands. These commands generate data and put the data into a threadsafe queue. I then have a function that takes the data from the ...
Angelo's user avatar
  • 3,113
1 vote
1 answer
34 views

Horizontal and vertical colorbars on a single plot in python

I have KDE plot generated using seaborn on which I overlay some scattered points with some size. I need to have two colorbars to represent the data of KDE and the scattered values's size (as shown ...
skm's user avatar
  • 5,639
0 votes
1 answer
44 views

Scatter plot showing data points with negative values when there are no negative values in the dataset

I have an issue with this linear regression model. The scatter plot shows data points well into the negative when no negative values are within the data set. I've checked the shapes and minimum values ...
leakie's user avatar
  • 1
0 votes
2 answers
40 views

Draw a Venn-diagram in python with one large area encompassing all other

I used so far succesffully this code: import matplotlib.pyplot as plt from matplotlib_venn import venn2 # Define the areas for the Venn diagram area1 = 13552 # Area of the left ellipse area2 = 7887 ...
NeStack's user avatar
  • 1,984
0 votes
0 answers
20 views

How to resize figure to fit window on event in matplotlib?

I've already got help with this problem, but stuck again. I'm trying to pre-generate and store matplotlib figures in python, and then display them on a keyboard event (left-right cursor keys). It is ...
lmocsi's user avatar
  • 1,086
2 votes
1 answer
33 views

How to increase the space between the subplots and the figure?

I'm using a python code to plot 3D surface. However, the z-axis label get cut by the figure. Here is the code : import matplotlib.pyplot as plt import numpy as np fig = plt.figure(figsize=(12, 10), ...
user28754841's user avatar
0 votes
0 answers
30 views

Three plots sharing x-axis on top of each other as in figure

I'm struggling with matplotlib. I'd like to get a plot like this one but with the code below I can only get this plot. f, (ax1, ax2, ax3) = plt.subplots(3, sharex=True, sharey=False) ax1 = plt.gca() ...
user123892's user avatar
  • 1,293
1 vote
1 answer
27 views

Python: Plotting a Basemap in the x-y-plane of a 3d plot

I am trying to get the code contained in https://basemaptutorial.readthedocs.io/en/latest/basemap3d.html to work. However, I get an error already in the first snippet: import matplotlib.pyplot as plt ...
ahul-fell-awen's user avatar
0 votes
0 answers
27 views

MatPlotLib FuncAnimation: Is there a way to show the gif as it saves?

I am currently experiencing an issue where I can either run an animation in Jupyter Notebook, or I can save it, but I can't do both. If I want to do both, I have to run the code twice, once with: ani....
lzzard's user avatar
  • 53
2 votes
1 answer
36 views

Mismatch between the volume shape and the axes grid in matplotlib

I have written a script to visualize a 3D volume using Matplotlib. The decay volume is explicitly centered at x = y = 0, but the grid displayed appears displaced relative to the volume. This seems to ...
McAddams's user avatar
0 votes
0 answers
38 views

How to speed up secondary_xaxis() in matplotlib? [closed]

I'm finding usage of secondary_xaxis() is extremely slow. I'd like to speed it up. To add a secondary axis at the top of the plot, I'm passing two functions to secondary_xaxis() both of which just ...
hjs's user avatar
  • 133
0 votes
0 answers
23 views

Matplotlib: making subscripts italicized

I'm using plt.text to display some texts in my figure. I want the whole text to be italicized, including subscripts. I've tried a number of ways and I just can't get the subscript to be italicized. ...
Barry Zheng's user avatar
2 votes
1 answer
40 views

matplotlib pretty print function for numbers [duplicate]

I'm trying to have some nice titles and annotation in matplotlib plots. For instance, I want to convert a number like 1e-3. in a katex/latex syntax : $1 \cdot 10^{-1}$, which will nicely appears on ...
Marti's user avatar
  • 89
0 votes
2 answers
53 views

How to enable automatic color cycling for Arc patches in matplotlib?

In this Python 3.12 script: import matplotlib.pyplot as plt from matplotlib.patches import Arc fig, ax = plt.subplots() for a1 in range(0, 360, 20): ax.add_patch(Arc((0, 0), 10, 10, theta1=a1, ...
Paul Jurczak's user avatar
  • 8,039
2 votes
2 answers
55 views

python: heatmap with categorical color and continuous transparency

I want to make a heatmap in python (seaborn, matplotlib, etc) with two dimensions of information. I have a categorical value I want to assign to color, and a continuous variable (i.e. between 0-100 or ...
andbeonetraveler's user avatar
0 votes
1 answer
66 views

Varying the arrowsize proportional to the linewidth in streamplots (matplotlib: 3.5.1)

I have fluid flow data, that has some vortices that decay in strength with distance in one direction. An easy example of this is below. import numpy as np # model flow field x = np.linspace(0, 2 * np....
vercors's user avatar
  • 21
1 vote
0 answers
58 views

Why can't Python find Matplotlib after installing Manim (in Windows 11)?

I am using Windows 11 on an HP laptop, purchased August 2024. I have installed Python, then added matplotlib (using the command line from PowerShell) and it seemed to be working (In PowerShell I ...
demneptune's user avatar
2 votes
2 answers
45 views

How to adjust the size of one subplot independently of other subplots in a matplotlib figure?

I want to have horizontally aligned 3D and 2D plots, where the y-axis of the 2D plot is the same height as the z-axis of the 3D plot. The following code produces a default output: import matplotlib....
Corvus's user avatar
  • 37
0 votes
1 answer
39 views

FuncAnimation only shows one frame

I am trying to implement a genetic algorithm in Python and to display the result of my algorithm I wanted to create an animation using FuncAnimation from matplotlib.animation. However, I ran into the ...
Andrew's user avatar
  • 45
0 votes
1 answer
49 views

How can I make a density plot with log-scaled axes in matplotlib?

I want to plot a scalar density as a function of two variables x and y, which can potentially be scaled logarithmically. I essentially run simulations for each pair of x and y and want to report the ...
David Zwicker's user avatar
0 votes
1 answer
35 views

matplotlib x axis not as expected

I want the x-axis labels to be exactly as in the file, but it's converting them. Also, I don't want the thick black line above the labels. And, I'd like the plot to extend fully to both sides of the ...
Mike's user avatar
  • 701
0 votes
1 answer
50 views

Visualization of ranking models based on time executions

I'm working on reproducing the following plot for my own case: so, let's say I already have my results ready and in the form of data frames as below: import pandas as pd # Data data1 = { 'Models'...
Mario's user avatar
  • 1,960
3 votes
1 answer
56 views

Plotting quiver plots in matplotlib

I want to plot the slope field for: 0.5*sin(0.5*pi*x)*sqrt(y+7) import numpy as np import matplotlib.pyplot as plt # Specify the grid of dots x = np.arange(-3,3,0.3) y = np.arange(-2,4,0.3) X, Y = ...
blackened's user avatar
  • 903
0 votes
0 answers
28 views

'Arrow3D' object has no attribute 'do_3d_projection'; set up X, Y, Z axis on 3D plane

The purpose of the code is to use arrow3D to initiate X, Y, Z axis on a 3D plane. The parameters of arrow3D are x, y, z, which default to zero; and dx, dy, dz, which is the length of X, Y, Z axis. ...
H.Li's user avatar
  • 33
0 votes
1 answer
33 views

changing the y axis in matplotlib

How can you change the y-axis in matplotlib such that you have specified ticks ([0, -1, -8, -44, -244]) but they are evenly spread over the y-axis (the gap between 0 and -1 is just as big as the gap ...
Max's user avatar
  • 3
0 votes
1 answer
44 views

How to sample point using LatinHyper Cube sampling in a random volume

I have a a dataset composed of XYZ coordinates, which can be rendered in 3D bar chart as the picture below. The main question I have is: how to generate X points (X being a user input) inside said ...
Ryderc's user avatar
  • 109
0 votes
2 answers
60 views

Edit legend of seaborn stacked barplot

I followed this tutorial to create a stacked double barplot, which worked nicely for my data, but now I'm trying to edit the legend to include the information needed to read the figure. I tried ...
Whitehot's user avatar
  • 487
1 vote
1 answer
21 views

Determine if matplotlib figure is still displayed (has not been closed)

When using matplotlib in interactive mode, I need to know, whether a figure has been closed or not. I'm tracking the figure handles for other purposes, but the event of closing the figure is decoupled ...
Martin Matoušek's user avatar
1 vote
1 answer
75 views

Problems plotting timestamps on the x-axis with Matplotlib

I am working on a Python script that loads several CSV files containing timestamps and ping data and then displays them on a plot. The X-axis is supposed to display the timestamps in HH:MM format, ...
Pantastix's user avatar
  • 340
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
1 answer
88 views

Why is the plot of the refractive index wavelength-dependent Fresnel's equation not showing as expected?

I want to reproduce the reflectance spectrum of a thin film whose complex refractive index is wavelength-dependent (the complex refractive index data, named N2 in code, can be obtained from here). ...
Pxndx's user avatar
  • 23
0 votes
0 answers
26 views

Place a ring on a cartopy plot projection

I want to place a ring on a map project. I would like to set the inner and outer radius and place the center anywhere I want. The needed imports: import cartopy import cartopy.crs as ccrs from cartopy ...
c186282's user avatar
  • 101
1 vote
1 answer
37 views

Plot contours from discrete data in matplotlib

How do I make a contourf plot where the areas are supposed to be discrete (integer array instead of float)? The values should discretely mapped to color indices. Instead matplotlib just scales the ...
ascripter's user avatar
  • 6,205
0 votes
0 answers
21 views

Stack 2d heatmaps on top of each to create 3d tomography plot in python [duplicate]

I am trying to understand how to create 3D tomography plots in python. I have created a list of correlation matrices, and I want to plot each correlation matrix as a 2d heatmap, where the color ...
KirkLab's user avatar
  • 19
-1 votes
2 answers
43 views

Python Matplotlib - How to plot a grouped bar chart

Suppose I already have the following labels list and data dict: labels = ["Label 1", "Label 2", "Label 3", "Label 4", "Label 5"] data = { "...
HelloVictor2000's user avatar
0 votes
1 answer
28 views

Put specific name on plt.title using DataFrame

I want to plot a graph with the column name in the title. For example: import pandas as pd begin_date = '2019-01-01' df = pd.DataFrame ({"date": pd.date_range(begin_date, periods=5), &...
Daniel M M's user avatar
0 votes
0 answers
23 views

Either incorrect spacing or incorrect size using matplotlib shared y axis and aspect equal

Context I'm trying to display some timing data of differing algorithms which depend on some input size and another parameter. The goal is to have n plots showing the various algorithms and one summary ...
Sam Coutteau's user avatar
0 votes
0 answers
51 views

How to substitute variables in a Python raw string? [duplicate]

I want the code snippet below to output a plot, with fraction 2.345 / 3.456 to be rendered using latex at the point (0.1, 0.9). I'm using python raw string along with f-strings in the call to ...
chelwin's user avatar
  • 13
2 votes
2 answers
55 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

1
2 3 4 5
1258