Questions tagged [mplot3d]

1

votes
0

answer
112

Views

Matplotlib.animation performance with Axes3D

I have played with creating HTML5 videos from matplotlib.animation.Artistanimation, it works well for both 2D and 3D images, but for the 3D version, the conversion to html5 video is very slow, like 200s for 35 frames. Given that it takes roughly 3 times longer to draw a 3D figure than a 2D figure,...
kakk11
1

votes
0

answer
147

Views

Matplotlib: save 3D volume plot to numpy array

Someone posted how to convert 2D Matplotlib images to a np.array. I'd like to do the same for a 3D Matplotlib plot. To be clear, I am not asking to save a 2D 'screenshot' of fig.canvas as an array, but rather a raster of the 3D lines as an array. Why? My raw data is a list of node id's, their (x,y,z...
crypdick
1

votes
0

answer
25

Views

Redrawing a plane with a slider

Given a 3D surface plot in matplotlib which is described by a plane in the form of Z = aX+by+d. Further given a slider by which the a-parameter of Z should be controlled. I got so far the following code: import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from...
Daniyal
1

votes
0

answer
155

Views

Matplotlib 3D workaround for plot order

I know that matplotlib 3D is not reliable for plotting multiple 3D objects (planes, lines, points) in the right order: please see Matplotlib 3D plot zorder issue and How to draw intersecting planes?. However these questions seem quite old, so the proposed solutions. Thus, I would like to know if the...
Chutlhu
1

votes
1

answer
59

Views

How to Animate Text in 3D Scatter Plot?

I would like to animate a 3D scatter plot where each data point has a text label that moves along with it. Right now the text labels do follow the data points as I want, but they persist through each frame; the text does not disappear from the last animation update. See image below. The data points...
Ben
1

votes
0

answer
28

Views

Changing aspect ratio of 3D plot in matplotlib [duplicate]

This question already has an answer here: matplotlib (mplot3d) - how to increase the size of an axis (stretch) in a 3D Plot? 6 answers set matplotlib 3d plot aspect ratio? 5 answers I am trying to plot a pointcloud using matplotlib and I would like to extend the time axis, while keeping the x and...
Mr Squid
1

votes
1

answer
87

Views

How to Suppress/Ignore(/Fix) matplotlib Axes3D ValueError?

As requested, here's the minimum, working example (below); my apologies that it's so much, but this seems to be an issue that requires overhead structure (specifically the presence of the 2d and 3d axes on two separate tabs at once, but not when 3d or 2d is alone): import sys, os pyDir = os.path.dir...
ees
1

votes
1

answer
2k

Views

3d plot in python based on matrix

I have a data set created by.... import random count = [] for i in range(1, 4): for j in range(3, 6): for k in range(15,19): count.append((i, j, k, random.random())) I would like to create 3d graphs of count vs pairs of i, j, and k (so 3 graphs total). I have looked through examples here: http://mat...
Joshua
1

votes
1

answer
2.1k

Views

Editing Python plot surface ticks and their frequency

Gist of my question: I have data that I am plot_surface-ing with python. How should I change the values of my xticks and yticks and perhaps their frequency? Details of my question I have data such as this. I had to upload my data file to dropbox as it is too large to reproduce here and I am not sure...
dearN
1

votes
1

answer
190

Views

Python: Continuous addition to a 3d scene in a loop

Can you give example code to initially draw a surface then draw some random lines in a loop. Between drawing each line, a little time is wasted, to give the impression of an animation. The code should work both from ipython and pydev.
ozi
1

votes
1

answer
209

Views

How to clear surface [duplicate]

This question already has an answer here: Matplotlib - How to remove a specific line or curve 4 answers I am trying to create a animation - first I draw a circle, then I want to redraw it. ax.plot_surface(x,y,z,rstride=5,cstride=5,color='r',linewidth=0.1,shade=0) # - this function To redraw it in a...
user2923317
1

votes
1

answer
1k

Views

Python - color a 3d line plot

I have a 3d line plot of the solar spectrum, which I plotted using the command, from mpl_toolkits.mplot3d.axes3d import Axes3D from matplotlib.collections import PolyCollection, LineCollection from matplotlib.colors import colorConverter, ListedColormap, BoundaryNorm import matplotlib.cm as cm fig =...
Pooja Kapadia
1

votes
1

answer
831

Views

3D matplotlib figure inside a Spyder terminal

I'm plotting a 3D plot in mathplotlib: fig = plt.figure() ax = fig.add_subplot(111, '3d') ax.scatter(x,y,z) plt.show() The figure however open in the terminal so I cannot inspect it. How can I open it in a new window for inspection? Thanks.
Roy
1

votes
1

answer
273

Views

mplot3d: contourf offset, limits and ticks

I'm trying to get a nice contourf plot under a mplot3d surface. I'd want it to appear on the floor of the 3d axis cube with a little offset from my data lower limits. Right now I'm doing something like this: import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt from mpl_toolkit...
filippo
1

votes
1

answer
265

Views

How to make a 3D plot in matplotlib from data z=f(x,y) read from file

I need to create a 3D plot in matplotlib. I am reading Z values from a text file formated as 1D array. This data represents value for every point on a 50x50 square. So first 50 values are for points (0,0),(1,0)..(49,0), next 50 are for (0,1),(1,1) and so on. So far i have written the following code:...
rodrykbyk
1

votes
1

answer
1.5k

Views

Color-mapping a 3D quiver function using matplotlib

I have created a lovely 3D displacement vector field in python using Matplotlib and I am happy with the results. However, visually it is not very east to see the magnitude of the displacements only the direction. Is there a way in python that I could use a colour scale for the arrows so that the mag...
Scott Alistair
1

votes
1

answer
269

Views

Trying to plot multivariate function in 3D matplotlib; returns empty figure

I am trying to plot a function F(x1,x2) in 3D matplotlib, follwoing a tutorial from here: http://glowingpython.blogspot.com/2012/01/how-to-plot-two-variable-functions-with.html Once I try to run the code, the figure turns out to be empty, not even the axes output is seen. I was wondering if anyone...
bhjghjh
1

votes
1

answer
374

Views

How can I speed up mplot3d's render?

I'm visualizing timestamped xy positions of objects using mplot3d. I would like to rotate and zoom into the resulting figure to better understand the details. Python is really slow at rendering the figure, making it almost impossible to do what I want. Is there a way to make the 3d-plot faster to ma...
autonomy
1

votes
1

answer
761

Views

Impose same colormap and colorbar to multiple 3D plot

The goal is to output two different 3D plots (plot_surface) providing specific colours for the surface (facecolors) in a 'fair' way, namely using the same scale of colours for the two figures (and the same x, y and z axis fixed, but this is easy). In addition, the colorbar must be the same (i.e. sam...
MLguy
1

votes
1

answer
462

Views

Multiple independent lines in the same 3D Axes

I would like to draw multiple independent lines in a 3D plot in Python. It looks like: . I am new at Python. Would you help me?
huangteng1220
1

votes
2

answer
253

Views

Change 3D background to black in matplotlib

I'm having trouble changing the background of my 3d graph to black. This is my current code. When I do set facecolor to black, it changes the inside of the graph to be grey, which is not what I want. fig = plt.figure() fig.set_size_inches(10,10) ax = plt.axes(projection='3d') ax.grid(False) ax.xaxi...
Ryan Tom
1

votes
1

answer
73

Views

surface plots for rectangular arrays in matplotlib

I am trying to use matplotlib to generate surface plot of a rectangular array (in my case, it's 47x70). The way this array is organized is: 47 - this dimension indicates the number of features 70 - this dimension indicates the number of samples The array contains values for these features across eac...
newtostack
1

votes
1

answer
58

Views

Fill in area between lines on 3D line plot Python

I have a 3D line plot with 13 lines on it. I want to shade in the area between the lines (along the y axis) to give it a shaded hill look. Is there a way to do this? I have tried converting the data I have to a 2D array so that I can make a surface plot of the x and y data, but the x data is 101 it...
Stephanie Mendez
1

votes
1

answer
0

Views

Python: given a plane equation draw a subset of points that belong to it

As the title say, let's assume I have a plane equation: ax+by+cz=d (e.g. -4x + 5y + 9z = -9) I want to draw n random points (let's say 500) that belong to that plane. Can somebody help me with that? I saw that from mpl_toolkits import mplot3d has the function plot_surface(x,y,z) but (as it says)...
Niccolò Cacciotti
1

votes
1

answer
0

Views

Matplotlib 3d plot: get single colormap across 2 surfaces

I am making a 3d plot with matplotlib with 2 surfaces (see example below). So far both surfaces get their own colormap, being blue in the bottom and yellow on top. However, I want a single colormap for both surfaces, i.e. the very bottom is blue, the very top is yellow and the touching point of both...
Hannebambel
1

votes
1

answer
1.7k

Views

Python 3d plot from data file, getting valueError

I am relatively new to python. I am doing different types of plots from data I have in a file. I successfully did a contour plot, and wanted to plot that same data on a 3D plot. So that data is already in X, Y and Z arrays. There are Nx X values, Ny Y values and Z is an (Nx,Ny) array. The most r...
jealopez
1

votes
1

answer
1.1k

Views

Plotting multiple 3D lines: data transformation

I would like to plot multiple lines in a 3D plot in Python. My input consists of two n x 3 arrays, say pos1 and pos2, corresponding to two lists of 3D points (row = x,y,z coordinates). I need to plot a line connecting the ith point in pos1 to the ith point in pos2, for each i. I have working code,...
Eric Kightley
1

votes
1

answer
318

Views

Pylab or mplot3d: index as marker

While plotting a list in pylab or mplot3d (2d or 3d scatter plot), is it possible to use the index in the list as marker? Or other ways (or other libraries) that can make the viewer understand which point in the list corresponds to which point on the graph. I've included a 3d scatter plot here just...
clwen
1

votes
1

answer
583

Views

matplotlib 3d scatter from 2d numpy array vertices error

I'm stumped as to why this is not working. I am pulling a bunch of floating point data in to a numpy array from a csv file, and I just want to create a 3d scatter plot based from 3 of the columns in the array. #import data from the csv file data = np.genfromtxt('data.csv', delimiter=',', dtype=floa...
Lundy
1

votes
1

answer
2k

Views

Matplotlib bar3d variable alpha

I'm using matplotlib bar3d with RdBu colormap and wanted to have variable transparency between bars (so smaller bars can be more transparent than taller bars). Here is the code for making the 3d bar plot. The data is stored in a 4x4 matrix 'rho'. At the moment alpha is kept at 0.95, but it would be...
Robert Chapman
1

votes
1

answer
466

Views

How can I connect two points in 3D scatter plot with arrow?

I am trying to connect two points in a 3D scatter plot with an arrow. I tried using quiver with the following code import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D fig = plt.figure(figsize=(20, 15)) ax = fig.add_subplot(111, projection='3d') xs1 = [40,50,34] ys1 = [30,30,30] z...
Akshay
1

votes
1

answer
664

Views

matplotlib contourf3d plot_surface vs. trisurf

I'm trying to do this with my data that has the following structure: 0.90000000 0.90000000 -2133.80472139 0.90000000 0.95000000 -2133.84134433 ... 1.87500000 1.82500000 -2133.96171262 1.87500000 1.87500000 -2133.95550450 With the following code, I've partially succeed. However, I can't plot...
1

votes
1

answer
990

Views

How to colour data points on a 3D scatterplot in matplotlib

Edit: I managed to figure out what was going on. Scatter has a parameter 'line-width' (lw=n) that determines the thickness of the line surrounding the plot point for a scatter plot. Because my plot points were size 1 (s=1), the line width was so thick it was actually covering the colour of the plot...
gsamerica
1

votes
1

answer
386

Views

How to Plot 2 Vectors in 3D

import numpy as np import matplotlib matplotlib.rcParams['backend'] = 'Qt4Agg' import matplotlib.pyplot as plt import seaborn as sns from mpl_toolkits.mplot3d import Axes3D fig = plt.figure() ax = fig.gca(projection='3d') %matplotlib inline p=np.array([1,-3,5]) q=np.array([3,2,6]) ax.quiver(p,q) ax...
Jeffrey Derose
1

votes
2

answer
316

Views

Stacked 2D plots with interconnections in Matplotlib

I need to visualize some complex multivariate datasets and the preferrable choice is to use a modification of parallel axis visualization, using stacked 2D plots, where each plot maps a degree of freedom/model parameter and data points belonging to the same data sets should be interconnected across...
maurizio
1

votes
1

answer
832

Views

Graph with multiple x and y axis using Matplotlib

As I checked with the Matplotlib document and other resources. I got that when multiple axis were created they are not depend on each other and we can plot the multiple line as per different axis. But I need to plot the graph like two Y-axis contains with the temperature as (Celsius and Fahrenheit)...
Jeenit khatri
1

votes
1

answer
159

Views

Using Matplotlib how to plot algebraic equations

Using Matplotlib, how can I plot the following algebraic equations in 3d? Would like to visualize the intersection of 3-planes. x - y + 2z = 5 y - z = -1 z = 3
Godekere
1

votes
2

answer
2k

Views

2D linear interpolation: data and interpolated points

Consider this y(x) function: where we can generate these scattered points in a file: dataset_1D.dat: # x y 0 0 1 1 2 0 3 -9 4 -32 The following is a 1D interpolation code for these points: Load this scattered points Create a x_mesh Perform a 1D interpolation Code: import numpy as np...
DavidC.
1

votes
2

answer
1.1k

Views

matplotlib plot_surface for 2-dimensional multiple linear regression

I have many points of data with three dimensions: x1, x2, and y. I'm able to calculate the multiple linear regression of these points, and I'm able to display the points on a 3D scatter plot, but I don't know how to plot the multiple linear regression I calculated for those points: the same way you...
Dmitry S.
1

votes
1

answer
115

Views

Plotting concave shape (lens focus) using mplot3d

I am currently trying to visualize the focal shape of a lens using matplotlib, specifically the mplot3d toolbox. I obtained the data from fitting ellipses to a set of microscope images at different focal lengths as major major and minor minor radius, as well as the rotation angle ang of said ellipse...
Christoph

View additional questions