matplotlib

How to display color as a function of distance to the origin in matplotlib's 3D surface plot?

╄→гoц情女王★ 提交于 2021-01-27 19:40:48
问题 I am trying to plot a certain function Q(theta, phi) in spherical coordinate using python's matplotlib package. I want the color to show up as a function of distance to the origin instead of the z coordinate. Is there a way to do this? Here is the code I use to produce the 3D surface plot: %matplotlib notebook fig = plt.figure(figsize=(12,12)) ax = fig.add_subplot(111, projection='3d') X, Y = Q*np.sin(Theta)*np.cos(Phi), Q*np.sin(Theta)*np.sin(Phi) Z = Q*np.cos(Theta) ax.plot_surface(X, Y, Z,

Plot not showing for animation matplotlib

坚强是说给别人听的谎言 提交于 2021-01-27 19:36:47
问题 I am trying to animate the numpy array C3, this is an array with one channel of electrode data and I want to plot it in real time using matplotlib. I have created my update function but nothing is printing out, I though the the syntax is you pass i through to loop through the plots and the FuncAnimation should do the rest. Can someone please point me in the right direction? Much appreciated! from matplotlib.animation import FuncAnimation import matplotlib.pyplot as plt data_skip = 50 def

How to display color as a function of distance to the origin in matplotlib's 3D surface plot?

孤街浪徒 提交于 2021-01-27 19:16:28
问题 I am trying to plot a certain function Q(theta, phi) in spherical coordinate using python's matplotlib package. I want the color to show up as a function of distance to the origin instead of the z coordinate. Is there a way to do this? Here is the code I use to produce the 3D surface plot: %matplotlib notebook fig = plt.figure(figsize=(12,12)) ax = fig.add_subplot(111, projection='3d') X, Y = Q*np.sin(Theta)*np.cos(Phi), Q*np.sin(Theta)*np.sin(Phi) Z = Q*np.cos(Theta) ax.plot_surface(X, Y, Z,

Reproduce same graph in NetworkX

笑着哭i 提交于 2021-01-27 19:13:42
问题 I would like to improve my graph. There are problems as follow: how to create a consistent graph.the graph itself is not consistent everytime i execute / run the code, it will generate different images. The inconsistent graph is shown in the url. how to customize the whole graph / picture size and to make it bigger how to set a permanent position for an object 'a' so that it will consistently appears at the first / top position how to customize length of arrow for each relationship.

How to create a heat-map with multiple colormaps?

笑着哭i 提交于 2021-01-27 19:05:23
问题 As illustrated below, I am looking for an easy way to combine two or more heat-maps into one, i.e., a heat-map with multiple colormaps. The idea is to break each cell into multiple sub-cells. I couldn't find any python library with such a visualization function already implemented. Anybody knows something (at least) close to this? 回答1: The heatmaps can be drawn column by column. White gridlines can mark the cell borders. import numpy as np from matplotlib import pyplot as plt a = np.random

Place Matplotlib errorbars NOT in center of bar

老子叫甜甜 提交于 2021-01-27 19:00:50
问题 I'm generating a stacked bar graph in Matplotlib with errorbars. Unfortunately, some of the tiers are relatively small and the data diverse, so that the errorbars of several tiers can overlap, making them hard or impossible to read. Example: Is there a way to set the location for each errorbar (i.e. move it along the x-axis), so the overlapping lines are displayed next to instead of on top of each other? 回答1: Thanks to tcaswell's comment, I figured it out: The trick is to not include the

Matplotlib path contains_point

删除回忆录丶 提交于 2021-01-27 18:57:36
问题 I've just discovered the matplotlib path functionality and I'm using it with path.contains_point to check whether points are found within a region defined by 2 bezier curves. I'm getting some unexpected behaviour where contains_point is returning True when I would have expected it to return False . Specifically, if the point to be tested is to the left of the region then it seems to be incorrect. On the right is ok. Defining my paths as a number of straight lines rather than curves seems to

IPython automatically turning on matplotlib interactive mode

a 夏天 提交于 2021-01-27 18:52:51
问题 I'm experiencing some newly odd behavior from IPython. I just had to do a clean reinstall of my miniconda, so I now have fresh IPython and Matplotlib versions. It turns out that IPython is automatically switching matplotlib to interactive mode (which has the annoying side effect of making my saved figures blank in my scripts, because they save after I close the window). Here's an example: Python 3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 21:52:21) Type 'copyright', 'credits' or

Matplotlib FuncAnimation not animating line plot

六月ゝ 毕业季﹏ 提交于 2021-01-27 18:29:42
问题 I have two random vectors which are used to create a line plot. Using the same vectors, I would like to animate the line but the animation is static - it just plot the original graph. Any suggestions on how to animate such a line plot? import numpy as np import matplotlib.pyplot as py from matplotlib import animation # random line plot example x = np.random.rand(10) y = np.random.rand(10) py.figure(3) py.plot(x, y, lw=2) py.show() # animation line plot example fig = py.figure(4) ax = py.axes

how to set the scale of Z axis equal to X and Y axises in python plot_surface

自作多情 提交于 2021-01-27 18:10:43
问题 I tried use plot_surface in matplotlib to plot a 3D surface. My code is: fig = plt.figure() ax = fig.gca(projection='3d') # ax.set_aspect('equal') ax.plot_surface(X, Y, H4200, rstride=1000, cstride=1000) ax.set_xlabel('X Label') ax.set_ylabel('Y Label') ax.set_zlabel('Z Label') # ax._autoscaleXon = True # ax._autoscaleYon = True # ax._autoscaleZon = True # ax.set_aspect('equal', adjustable='box') plt.show() the result of the plot are: 1: 2: obviously, the length of Z units is not equal to the