391 questions
3
votes
1
answer
458
views
How to add text on surfaces of cubes
How to add text on surfaces of cubes. I'm trying to solve 3d packing problem but i have problem visualization because if there were 1000 cubes, how to identify each of them.So i need to write number ...
0
votes
0
answers
305
views
Plot surface of a cube in Matplotlib
I am trying to project a 3D cube onto a 2D image and I am looking for an effective way to draw the surface of this cube. I'd like to avoid using some of the existing solutions such as wire_frame, as ...
1
vote
0
answers
175
views
Plotting a 3d polynomial in python
I have a polynomial function, let’s say a+bx+cx^2. I show the function in a 2d plot, but I want to progress to show it in 3d. But not just showing it, giving it height, so if I have x,y I set a Z1 ...
3
votes
0
answers
732
views
Poly3DCollection - set face color by scalar field defined over vertices with linear gradient
Problem summary
I have a mesh made by quadrilateral elements with a scalar field defined over the nodes of the elements. I am using Poly3DCollection to plot the mesh with the elements coloured by the ...
0
votes
0
answers
675
views
I get ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (1000,) and requested shape (1000,1)
# In order to use the 3D plot, the objects should have a certain shape, so we reshape the targets.
# The proper method to use is reshape and takes as arguments the dimensions in which we want to fit ...
1
vote
1
answer
521
views
How to plot a 3D plot
I have an array of Clusters using Dimensionality Reduction n = 2 and it is plotted in 2D with the following code:
f, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(24,6))
# labels = ['No Fraud', 'Fraud'...
0
votes
1
answer
230
views
bar plot in 3d following a given line
I want to draw a bar plot in 3d. I know how to do that using the following code:
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure(figsize=(10,...
0
votes
1
answer
132
views
Creating 3d plot from lists
I am trying to make a 3D plot from the following lists:
X-axis:
S = [1.0, 3.0, 5.0, 7.0, 9.0,11.0,13.0,15.0,17.0]
Y-axis:
T = [0.25,0.5,1,2,3,5]
Z-axis:
Diff_025 = [-0.0, -0.0001, -0.0002, -0.0027, ...
1
vote
1
answer
710
views
Add constant x, y, z lines into 3D scatter plot
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
2
answers
680
views
3d quiver plot from .npy data files to give a 3d vector field
I want to plot a 3d velocity vector field using a 3d quiver plot in python, from 3 data files (.npy) that give u, v and w components of velocity in the x, y and z directions. This what I have done so ...
0
votes
1
answer
594
views
Hide tick text but keep grid for 3D-plot
I have searched far and wide for a way to remove the tick text but not the actual grid lines from a 3D matplotlib plot. I unfortunately still have no idea how to do it, as most solutions seem to only ...
0
votes
0
answers
104
views
Calculate normal vectors for each element of a grid
Is there a function to calculate rapidly the normal vectors of each of the meshes of my grid? I'm looking to have vectors of the form n = [nx, ny, nz], for the example below it is easy to calculate it ...
1
vote
1
answer
59
views
Setting coordinates for sphere
I have a code that produces a sphere. I want to change the coordinates in which the sphere spawns
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits import mplot3d
from matplotlib ...
1
vote
2
answers
6k
views
Plot 3d points (x,y,z) in 2d plot with colorbar
I have computed a lot (~5000) of 3d points (x,y,z) in a quite complicated way so I have no function such that z = f(x,y). I can plot the 3d surface using
import numpy as np
import matplotlib.pyplot as ...
1
vote
0
answers
304
views
Plotting in 3d does not render correctly
I am trying to plot a number of components in 3d space (in python), but am having issues with the rendering. As an example, the code below plots a sphere with some points on its surface, a ring ...
0
votes
1
answer
553
views
How to plot data stream in 3D
Program Description: I have a phone sending gyroscope data every 2 seconds to a server. Every second I retrieve data from the server. The purpose of my program is to read this data stream and make a ...
0
votes
1
answer
677
views
Adding a colorbar by the dates of points in a 3D scatter plot
I am attempting to plot earthquakes of a certain region in a 3D plot with the color as a way to show time/date of the event. The data points are accurately colored, however, when I plot the color bar ...
2
votes
2
answers
4k
views
Convert 3D .stl file to JPG image
How do I convert a 3D object in any STL file into a JPG or PNG image.
I tried searching a little bit online but I wasn't been able to arrive at finding any possible solutions.
Can anyone help me with ...
0
votes
1
answer
488
views
How to generate the following Dataset to plot in 3D
I have been trying for around 2 days now to create the 2 half-moons data set in 3 dimensions.
First, I did it in two dimensions, and this link is very helpful for understanding how to plot the data ...
1
vote
0
answers
81
views
How to add color and drape to 3D plot
I have used the following code:
import numpy as np
import matplotlib.pyplot as plt
def f(x, y):
return ( ((np.log(x**2) / np.log(y**3)) / x**2 )*500)
x = np.linspace(0, 600, 4)
y = np.linspace(0, ...
0
votes
1
answer
257
views
Quiver to [0,0,0] isn't showing
I am trying to build a plot in 3d with matplotlib which has a dot at [0,0,0] and a quiver (vector) "looking" to it from [10, 10, 10]. But when I run the code I only get the dot. Why is that ...
0
votes
1
answer
697
views
3d z axis-log plot
In order to create a 3d plot using plot_surface and wireframe I wrote this (looking here around)
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
from matplotlib import rc
from ...
0
votes
0
answers
350
views
How can I reverse the axes in 3d graph?
Just starting with 3D plotting in Matplotlib. In the image below, how can I reverse the x and y axes and have a common origin of 0 for both the axes as written in red ink ? I could not find something ...
0
votes
0
answers
132
views
How to plot two 3D histograms in one figure
I would like to plot two 3D Histograms in the same figure so as to compare them. I would prefer if the colors were translucent so that the two bars of different colors remain distinguishable to the ...
0
votes
2
answers
1k
views
Plot a 3D figure in a 2D frame
In my current project, I want to plot a 3D shape with pyplot. This is relatively straightforward:
The complication comes from the fact that I would like the figure to display in a straight 2D figure ...
1
vote
1
answer
406
views
How to remove offsets in 3D projection plot?
I realized a slight "misalignment" of a plot I'm making in 3D with matplotlib. Here is an MWE:
import numpy as np
from matplotlib import pyplot as plt
figure = plt.figure(figsize=(8,10.7))
...
0
votes
1
answer
892
views
How to share 2D axis on a 3D plot
I am able to plot a 3D surface plot with a 2D contour plot just fine
but I would also like to share the x axis of the 2D plot using ax.twinx() like I've done in a separate plot here:
However, when I ...
0
votes
0
answers
115
views
scattering a set of 3d points over time
I have a data set of the following class:
class Event:
def __init__(self, timestamp, lx, ly, lz, nature):
try:
self.timestamp = datetime.strptime(timestamp, "%d/%m/%Y %H:%M")
...
0
votes
1
answer
3k
views
Animate points with matplotlib
I want to have 10 moving points. I used the code below. I'm experimenting with matplotlib which I don't know very well.
from matplotlib import pyplot as plt
import numpy as np
from matplotlib import ...
0
votes
1
answer
2k
views
How to format 3d subplots
So I have 8 3d plots (7 3d plots and one 2d plot)
I want to position them in 4 x 2 format. Here is my code for it:
sensor_data = self._util_sensor(sub_df)
fig = plt.figure()
fig.tight_layout()
ax = ...
0
votes
1
answer
6k
views
How to plot a line in 3 dimensional space
I have two 3D-points, for example a = (100, 100, 10) and b = (0, 100, 60), and would like to fit a line through those points.
I know, the 3D line equation can have different shapes:
Vector-form:
(x,...
1
vote
1
answer
544
views
How to plot the rotation of a curve along the x-axis
I would like to plot the line:
(x^2)/11.39 + (y^2)/6.25 = 1
rotated around the x-axis for a project I am working on.
I have used matplotlib to graph some 3D planes before but am unable to figure out ...
0
votes
1
answer
959
views
Matplotlib hide bar in bar3d if height is zero
I have seen matplotlib invisible bar if height is zero - however, that is for the 2D case of bar plot, so I couldn't quite apply it to my problem.
I have also seen Make transparent color bar with ...
1
vote
1
answer
2k
views
3D plot using equation with x and y
I'd like to create a 3D plot from an equation with x and y, similar to Google's 3D graph.
An example:
input: sin(sqrt(x**2 + y**2))
output (3D plot):
The Z will obviously be equal to the given input, ...
1
vote
1
answer
933
views
Fit 3d plot into the fixed-sized figure
This question is related to Set size of matplotlib figure with 3d subplots.
Here is an exmple code.
fig = plt.figure()
fig.set_size_inches(10, 4)
ax = fig.gca(projection='3d')
The code above is the ...
-1
votes
1
answer
769
views
Adjust the distance between zticks and Z axis in the 3D plot
The zticks and Z axis are overlapping in a 3D plot. How to adjust the spacing between these two?
I think this is happening because of the because of more number digits after the decimal point.
1
vote
1
answer
2k
views
Set_xlim and set_ylim not working for contourf in 3d plot
I want to create a 2d slice contour plot in 3d with the range of x and y larger than the given xlim and ylim. However, when I set xlim and ylim the contour seems to be extended outside of the axes. I ...
2
votes
1
answer
3k
views
How do I plot a 3D vector field?
The Data
I have a vector field, which is 0 in all components except for the z component. I just have the data for one slice of this field. My goal is to show this slice in a 3D plot.
The slice:
...
0
votes
1
answer
232
views
Color map for 3d bar plot where the color is with respect to an independent value
I want to have my color bar change with each element and represent the Ionization # in the data set below:
Ionization # Name Nebulizer 1 Nebulizer 2 Nebulizer 3
0 4.341 Potassium ...
1
vote
0
answers
1k
views
How to plot 3D bar plot on log scale
My data needs to be plotted on a log scale in order to be able to see some of my really small values, however, I can't seem to find any way to do it on a 3D bar plot.
Supposedly in a 2D bar plot you ...
0
votes
1
answer
322
views
3D quiver plot video using 3D arrays
I am attempting to create a 3d quiver plot of velocity vectors, using 3 arrays containing the vectors in x, y, z space with respect to time. I.e. a video of the quiver plot. Can someone help with this?...
0
votes
1
answer
860
views
How do I increase the gap of 3D bar chart in y-axis?
I have a 4*7 3D bar chart where I would like to increase the gap or spacing of the 7 bars in the y-axis.
Below is my code:
import pandas as pd
import matplotlib.pyplot as plt
from mpl_toolkits....
2
votes
1
answer
1k
views
How to plot barplot 3D projection for multiple columns
I have a table that contains three different time characteristics according to two different parameters. I want to plot those parameters on x and y-axis and show bars of the three different times on ...
4
votes
2
answers
9k
views
Set axis limits on a 3d plot
I want to set axis limits in matplotlib 3D plot to get rid of the value over 15,000.
I used 'set_zlim', but happened some error on my results.
how can I do?
from mpl_toolkits.mplot3d import Axes3D
...
0
votes
1
answer
1k
views
Plot 3D scatter plot from 3D array
I am currently trying to plot a 3D scatter plot by using a 3D array.
What I found online about plotting 3D scatter plot looks something like
ax.scatter3D(x, y, z) where x, y , z are all 1D array.
...
1
vote
1
answer
512
views
How to gray out previous trajectory of in 3D pixel tracking
I have 3 lists which contain the x cordinates, y coordinates and z coordinates respectively. I am trying to track the position in 3D space. I use the below code:
fig = plt.figure()
ax = p3.Axes3D(fig)
...
0
votes
1
answer
3k
views
Plotting histograms on 3D axes
I am trying to plot a few histograms on a 3d axis using the PolyCollection function, my desired plot looks something like this: (except of course the coloured plots are histograms)
For me, my x-...
1
vote
1
answer
2k
views
How to zoom_in 3D plot
I have a dataset I display it in 3D. now I have to look deep into that 3D plot. because there is a hole in it and I have to find it. Now I don't know how to do it. The 3D I display.
and I want to ...
2
votes
0
answers
6k
views
How to make error bars for a 3D Bar graph?
I'm new to coding and am trying to Frankenstein a graph for a research presentation. I would like to add an error bar to each bar value. Any help would be really appreciated. This is what I have so ...
5
votes
1
answer
6k
views
Plotting spheres of radius R
How can we make spheres of radius R centered at given coordinates(x,y,z). Like if there are 10 set of coordinates for the centers of the spheres and correspondingly 10 different values of the radii. ...