matplotlib

plotting two matrices in the same graph with matplotlib

杀马特。学长 韩版系。学妹 提交于 2021-01-27 18:00:27
问题 I want to plot two matrices in the same graph. These matrices have the shape 3x5. They were created using meshgrid for two arrays of the size 3 & 5 (a is size 3, b is size 5). The entries of the matrices were calculated using the values from the arrays, which I want to show in the plot, so e.g. if M1 was calculated with the entries a1 and b1, M1 should be shown where the two indices meet in the diagram. Also, the axis of the diagram should be labeled with the entries of the two arrays. To

Align x-axis ticks in shared subplots of heatmap and line plots using Seaborn and Matplotlib

邮差的信 提交于 2021-01-27 17:42:09
问题 Plotting a heatmap and a lineplot using Seaborn with shared x-axis, the ticks of the heatmap are placed in the middle of the heatmap bars. Consequently, the bottom lineplot will inherit heatmap ticks position and labels, not reflecting the true data as the lineplot ticks should start from zero. In other words, I need to either shift the ticks of both plots to start from the x-axis origin (optimal), or shift the lineplot toward the right by a half of a heatmap cell width, keeping the tick

Python matplotlib doesn't show full date on mouse hover

别来无恙 提交于 2021-01-27 17:10:00
问题 I have a dataframe with date index and temperature values : Date Temperature 2015-10-21 9.118 2015-10-22 9.099 2015-10-23 8.945 2015-10-26 8.848 2015-10-27 8.848 2015-10-28 8.829 2015-10-30 8.935 2015-11-02 9.302 2015-11-03 9.012 2015-11-04 9.109 ... 2017-10-16 10.160 2017-10-17 10.180 2017-10-18 10.140 2017-10-19 10.370 2017-10-20 10.360 Plotting it using interactive %matplotlib notebook shows the temperature, year/month on the bottom right, but omits the day . #%matplotlib notebook import

multicolored line with strings linecolllection

痞子三分冷 提交于 2021-01-27 14:03:00
问题 I'm using linecollection from matplotlib in order to create multi colored line similar to this example: http://matplotlib.org/examples/pylab_examples/multicolored_line.html but instead of using x and y both float types, I was wondering if its possible to create a line where x axis would be strings lets say: x= ['a','b','c','d','e','f','g','h','j','k'] . So every of those strings has a value for example y=np.arange(10) . So is plotting a multicolored line that connects those xy points using

Adjusting the position of a matplotlib floating axis in a subplot, and reversing an axis direction

…衆ロ難τιáo~ 提交于 2021-01-27 13:49:36
问题 This question leads on from a previous question I asked yesterday that got me most of the way to what I am after: Rotate transformation on matplotlib axis in subplot I want to create a two by two array of graphs where the bottom-left is a scatter plot and the other three are histograms projecting the x, y, and x-y data from that plot. That final histogram I want to have at a 45 degree angle, and it is the positioning of that plot which I am trying to adjust. Currently, I have this: from

Python quiver plot without head

99封情书 提交于 2021-01-27 12:54:36
问题 I'd like to make a quiver plot without the heads of the arrows. I also want to have borders so that the arrows could stand out of the background color plot. Here is the main part of my code trying to produce such a plot: plt.quiver(phia[sl1,sl2], R0a[sl1,sl2],u,v, color='white', headlength=0, headwidth = 1, pivot = 'middle', scale = scale, width=width, linewidth = 0.5) The plot is in polar axis if this matters. This works for most of the lines except for those that are very short. Some

How to hatch PolyCollection instance?

假装没事ソ 提交于 2021-01-27 12:42:45
问题 Is it possible to hatch PolyCollection instance? I want to hath a PolyCollection returned from fill_betweenx. import matplotlib.mlab as mlab from matplotlib.pyplot import figure, show import numpy as np x = np.arange(0.0, 2, 0.01) y1 = np.sin(2*np.pi*x) y2 = 1.2*np.sin(4*np.pi*x) fig = figure() ax1 = fig.add_subplot(111) PC = ax1.fill_betweenx(x, 0, y1) # I want to do something like this # PC.set_hatch('\') # but there is no such method show() 回答1: It's a bit of a hack, but you should be able

overflow error Plot

假装没事ソ 提交于 2021-01-27 12:15:51
问题 I want do stuff with sound/ audio and music processing. Before this i created a sample signal with a 10 second sweep. I have a simple script which have to plot some signals. First signal is a simple sine; second a sweep; Both with frequency just below Nyquist frequency so thats no problem. The Code: #import import numpy as np import scipy.signal as sig import matplotlib.pylab as plt f0 = 50 f1 = 20000 t1 = 10 t = np.arange(0,t1,1/44100)#[numpy.newaxis]; print(t.shape) sine = np.sin(2*np.pi*f0

matplotlib polar plot tick/axis label position

冷暖自知 提交于 2021-01-27 12:13:40
问题 I have been looking for a way to reliably position the tick and axis labels in a plot in polar coordinates. Please take a look at the following example: import numpy as np import matplotlib.pyplot as plt fig = plt.figure(figsize=[10, 5]) ax0 = fig.add_axes([0.05, 0.05, 0.4, 0.9], projection="polar") ax1 = fig.add_axes([0.55, 0.05, 0.4, 0.9], projection="polar") r0 = np.linspace(10, 12, 10) theta0 = np.linspace(0, 0.1, 10) ax0.quiver(theta0, r0, -0.1, 0.1) ax1.quiver(theta0 + np.pi, r0, -0.1,

How to graph nodes on a grid in networkx

为君一笑 提交于 2021-01-27 11:55:24
问题 Just started learning Network Science and I'm a novice in Python so I've been having a hard time figuring this out even after reading a good bit of the networkx documentation. I need to compare the distance between all the nodes and generate an edge in the event the distance is less than d. 1) How to I compare node 1 to nodes (2...99) and then compare node 2 to nodes (3...99), etc. If there's a better way to do it than O(n^2) please show me. 2) How can I use the x,y coordinates stored in node