matplotlib

why does my convolution routine differ from numpy & scipy's?

吃可爱长大的小学妹 提交于 2021-01-27 05:56:45
问题 I wanted to manually code a 1D convolution because I was playing around with kernels for time series classification, and I decided to make the famous Wikipedia convolution image, as seen here. Here's my script. I'm using the standard formula for convolution for a digital signal. import numpy as np import matplotlib.pyplot as plt import scipy.ndimage plt.style.use('ggplot') def convolve1d(signal, ir): """ we use the 'same' / 'constant' method for zero padding. """ n = len(signal) m = len(ir)

How do I use pylab to plot a phase plane for pendulum motion?

折月煮酒 提交于 2021-01-27 05:21:25
问题 I have code that will work for plotting the following predator prey model: dx/dt = x − xy, dy/dt = −y + xy from pylab import * xvalues, yvalues = meshgrid(arange(0, 3, 0.1), arange(0, 3, 0.1)) xdot = xvalues - xvalues * yvalues ydot = - yvalues + xvalues * yvalues streamplot(xvalues, yvalues, xdot, ydot) show() But I am not sure how to use these functions to draw a phase plane (using streamplot) to model pendulum motion, defined as d^2θ/dt^2 = (−g/L)sin(θ) How can I implement this model to

Formatting date labels on bar plot

二次信任 提交于 2021-01-27 04:52:14
问题 My question Suppose I have a Series like this. In[10]: month_series Out[10]: 2016-01-01 4880 2016-02-01 4579 2016-03-01 6726 2016-04-01 1778 2016-05-01 3303 2016-06-01 5402 2016-07-01 1207 2016-08-01 6176 2016-09-01 5586 2016-10-01 2802 2016-11-01 6944 2016-12-01 3580 2017-01-01 9336 dtype: int64 I want to just construct a bar plot to compare month to month, which seems quite simple with In[11]: month_series.plot(kind='bar') Out[11]: I really don't need anything much more than that, but my

How to size my imshow?

元气小坏坏 提交于 2021-01-27 04:49:29
问题 I generated a 2d intensity matrix with the following code: H, x_e, y_e = np.histogram2d(test_y, test_x, bins=(y_e, x_e)) The values of x_e and y_e are: x_e array([ 0.05 , 0.0530303 , 0.05606061, 0.05909091, 0.06212121, 0.06515152, 0.06818182, 0.07121212, 0.07424242, 0.07727273, 0.08030303, 0.08333333, 0.08636364, 0.08939394, 0.09242424, 0.09545455, 0.09848485, 0.10151515, 0.10454545, 0.10757576, 0.11060606, 0.11363636, 0.11666667, 0.11969697, 0.12272727, 0.12575758, 0.12878788, 0.13181818, 0

How to size my imshow?

試著忘記壹切 提交于 2021-01-27 04:49:14
问题 I generated a 2d intensity matrix with the following code: H, x_e, y_e = np.histogram2d(test_y, test_x, bins=(y_e, x_e)) The values of x_e and y_e are: x_e array([ 0.05 , 0.0530303 , 0.05606061, 0.05909091, 0.06212121, 0.06515152, 0.06818182, 0.07121212, 0.07424242, 0.07727273, 0.08030303, 0.08333333, 0.08636364, 0.08939394, 0.09242424, 0.09545455, 0.09848485, 0.10151515, 0.10454545, 0.10757576, 0.11060606, 0.11363636, 0.11666667, 0.11969697, 0.12272727, 0.12575758, 0.12878788, 0.13181818, 0

How to display LaTeX f-strings in matplotlib [duplicate]

£可爱£侵袭症+ 提交于 2021-01-27 04:24:29
问题 This question already has an answer here : Format a string that has extra curly braces in it (1 answer) Closed 12 months ago . In Python 3.6, there is the new f-string to include variables in strings which is great, but how do you correctly apply these strings to get super or subscripts printed for matplotlib? (to actually see the result with the subscript, you need to draw the variable foo on a matplotlib plot) In other words how do I get this behaviour: var = 123 foo = r'text$_{%s}$' % var

How to display LaTeX f-strings in matplotlib [duplicate]

冷暖自知 提交于 2021-01-27 04:24:19
问题 This question already has an answer here : Format a string that has extra curly braces in it (1 answer) Closed 12 months ago . In Python 3.6, there is the new f-string to include variables in strings which is great, but how do you correctly apply these strings to get super or subscripts printed for matplotlib? (to actually see the result with the subscript, you need to draw the variable foo on a matplotlib plot) In other words how do I get this behaviour: var = 123 foo = r'text$_{%s}$' % var

How can I draw axis lines inside a plot in Matplotlib?

拜拜、爱过 提交于 2021-01-27 04:08:13
问题 When I plot data using Matplotlib, the axes are always plotted by default as a box framing the plot. Let's say I am plotting data within axis limits -2 < x < 2 and -2 < y < 2 , but I would like to draw axis lines inside this plot area through the origin, preferably with ticks and tick labels along these axis lines - not along the outer frame. 回答1: This is well documented in the spines example (old link) / spine placement demo (new link). You are going to turn off the right and top spines (e.g

How can I draw axis lines inside a plot in Matplotlib?

谁说胖子不能爱 提交于 2021-01-27 04:07:58
问题 When I plot data using Matplotlib, the axes are always plotted by default as a box framing the plot. Let's say I am plotting data within axis limits -2 < x < 2 and -2 < y < 2 , but I would like to draw axis lines inside this plot area through the origin, preferably with ticks and tick labels along these axis lines - not along the outer frame. 回答1: This is well documented in the spines example (old link) / spine placement demo (new link). You are going to turn off the right and top spines (e.g

Matplotlib: how to load and show a PDF image

点点圈 提交于 2021-01-27 04:00:17
问题 My problem is simple: I have a PDF figure I would like to show alongside the results of some data analysis. Yet even an extensive Google search did not bring up a way to load and show a PDF in a figure (I only found the standard results for raster images like JPG or PNG). Thanks in advance! 回答1: I don't think Matplotlib supports plotting imported vector graphics on its own as of today. The easiest approach would probably be to save your figure generated in Matplotlib to SVG, convert your PDF