mplot3d

Colorbar for matplotlib plot_surface using facecolors

拈花ヽ惹草 提交于 2019-12-04 01:48:46
问题 I'm trying to plot in 3D colouring the surface with predefined colours using facecolors . The problem here is that cm.ScalarMappable normalizes surface V of colours while plt.cm.jet don't normalizes, so there is a mismatch of colours and colorbar. I've manually tried to normalize V (i.e. V_normalized ) but the result is still not quite correct. In fact, the highest value of V should be in a corner of the surface, but this is not reflected in the image in practice. How to plot ensuring to have

How to color a specific gridline/tickline in 3D Matplotlib Scatter Plot figure?

自闭症网瘾萝莉.ら 提交于 2019-12-03 23:11:21
问题 I am trying to modify the color/thickness of a specific gridline in a 3D matplotlib scatter plot, in this case I want the -30 z axis grid line to be black, bold, or thickened so it stands out amongst the other gridlines. Here is the basic code seen from the mplot3d scatter plot tutorial: import numpy as np from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt def randrange(n, vmin, vmax): return (vmax-vmin)*np.random.rand(n) + vmin fig = plt.figure() ax = fig.add_subplot(111

python draw parallelepiped

别来无恙 提交于 2019-12-03 17:39:25
问题 I am trying to draw a parallelepiped. Actually I started from the python script drawing a cube as: import numpy as np from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt points = np.array([[-1, -1, -1], [1, -1, -1 ], [1, 1, -1], [-1, 1, -1], [-1, -1, 1], [1, -1, 1 ], [1, 1, 1], [-1, 1, 1]]) fig = plt.figure() ax = fig.add_subplot(111, projection='3d') r = [-1,1] X, Y = np.meshgrid(r, r) ax.plot_surface(X,Y,1, alpha=0.5) ax.plot_surface(X,Y,-1, alpha=0.5) ax.plot_surface(X,

Surface and 3d contour in matplotlib

纵然是瞬间 提交于 2019-12-03 17:13:30
问题 I would like to plot a surface with a colormap, wireframe and contours using matplotlib . Something like this: Notice that I am not asking about the contours that lie in the plane parallel to xy but the ones that are 3D and white in the image. If I go the naïve way and plot all these things I cannot see the contours (see code and image below). import numpy as np from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(111, projection="3d"

matplotlib 3d axes ticks, labels, and LaTeX

喜欢而已 提交于 2019-12-03 11:31:28
问题 I am running this sample script, with the following modifications: import matplotlib as mpl from mpl_toolkits.mplot3d import Axes3D import numpy as np import matplotlib.pyplot as plt mpl.rcParams['legend.fontsize'] = 10 fig = plt.figure() ax = fig.gca(projection='3d') theta = np.linspace(-4 * np.pi, 4 * np.pi, 100) z = np.linspace(-2, 2, 100) r = z**2 + 1 x = r * np.sin(theta) y = r * np.cos(theta) ax.plot(x, y, z, label='parametric curve') ax.legend() ax.set_xlabel('$X$', fontsize=20,

Arrows in matplotlib using mplot3d

痞子三分冷 提交于 2019-12-03 10:20:17
问题 I am trying to use matplotlib to recreate the diagram on this page: http://books.google.co.uk/books?id=sf9Qn9MS0ykC&pg=PA18 Here is what I have so far: import numpy as np from matplotlib import pyplot as plt from mpl_toolkits.mplot3d import Axes3D from matplotlib.patches import FancyArrowPatch from mpl_toolkits.mplot3d import proj3d class Arrow3D(FancyArrowPatch): def __init__(self, xs, ys, zs, *args, **kwargs): FancyArrowPatch.__init__(self, (0,0), (0,0), *args, **kwargs) self._verts3d = xs,

Matplotlib 3D Bar chart: axis issue

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 08:51:11
I am having issue with getting data on x,y,z axis..below is my code. Is there any issue with the way i have defined range(dx,dy.dz) for different axis. result=[['122', '109', '2343', '220', '19'], ['15', '407', '37', '10', '102'], ['100', '100', '100', '100', '100'], ['113', '25', '19', '31', '112'], ['43', '219', '35', '33', '14'], ['132', '108', '256', '119', '14'], ['22', '48', '352', '51', '438']] from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import matplotlib.ticker as ticker import matplotlib.dates as dates def format_date(x, pos=None): return dates.num2date(x)

Surface and 3d contour in matplotlib

只谈情不闲聊 提交于 2019-12-03 07:08:28
I would like to plot a surface with a colormap, wireframe and contours using matplotlib . Something like this: Notice that I am not asking about the contours that lie in the plane parallel to xy but the ones that are 3D and white in the image. If I go the naïve way and plot all these things I cannot see the contours (see code and image below). import numpy as np from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(111, projection="3d") X, Y = np.mgrid[-1:1:30j, -1:1:30j] Z = np.sin(np.pi*X)*np.sin(np.pi*Y) ax.plot_surface(X, Y, Z, cmap

python draw parallelepiped

a 夏天 提交于 2019-12-03 06:28:15
I am trying to draw a parallelepiped. Actually I started from the python script drawing a cube as: import numpy as np from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt points = np.array([[-1, -1, -1], [1, -1, -1 ], [1, 1, -1], [-1, 1, -1], [-1, -1, 1], [1, -1, 1 ], [1, 1, 1], [-1, 1, 1]]) fig = plt.figure() ax = fig.add_subplot(111, projection='3d') r = [-1,1] X, Y = np.meshgrid(r, r) ax.plot_surface(X,Y,1, alpha=0.5) ax.plot_surface(X,Y,-1, alpha=0.5) ax.plot_surface(X,-1,Y, alpha=0.5) ax.plot_surface(X,1,Y, alpha=0.5) ax.plot_surface(1,X,Y, alpha=0.5) ax.plot_surface(-1

Connecting two points in a 3D scatter plot in Python and matplotlib

℡╲_俬逩灬. 提交于 2019-12-03 05:18:40
In the code below, how do I create lines connecting each pair of scatter plots (i.e. linking the green circle to the yellow arrowhead) created by the two lines of code towards the end just before the .show() instruction? import matplotlib.pyplot from mpl_toolkits.mplot3d import Axes3D dates = [20020514, 20020515, 20020516, 20020517, 20020520] highs = [1135, 1158, 1152, 1158, 1163] lows = [1257, 1253, 1259, 1264, 1252] upperLimits = [1125.0, 1125.0, 1093.75, 1125.0, 1125.0] lowerLimits = [1250.0, 1250.0, 1156.25, 1250.0, 1250.0] zaxisvalues0= [0, 0, 0, 0, 0] zaxisvalues1= [1, 1, 1, 1, 1]