matplotlib

Print highest peak value of the frequency domain plot

不羁岁月 提交于 2021-01-28 20:45:01
问题 I've attempted to plot the oscillations of my home made quad in the time and frequency domain. How do I print the value of my highest peak in the frequency domain plot? code: import matplotlib.pyplot as plt import numpy as np from scipy import fft, arange csv = np.genfromtxt ('/Users/shaunbarney/Desktop/Results/quadOscillations.csv', delimiter=",",dtype=float) x = csv[:,0] y = csv[:,1] x = x - 6318 #Remove start offset av=0 for i in xrange(1097): #Calculate average sampling time in seconds

rotating the z-axis in matplotlib 3d figure

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-28 20:18:55
问题 How do I rotate the z-axis of a matplotlib figure so that it appears as the horizontal axis? I have created the following 3d figure : I tried adjusting the values in ax.view_init() but no matter what values I used, I can't flip the z-axis so that the orientation of the three axes appear as like the ones in the following figure: I thought of changing the three components of all the data so that I use the x-axis to plot the z-component of the data, but then it will be very inconvenient to many

Plotting a discrete variable over time (scarf plot)

▼魔方 西西 提交于 2021-01-28 20:00:33
问题 I have time series data from a repeated-measures eyetracking experiment. The dataset consists of a number of respondents and for each respondent, there is 48 trials. The data set has a variable ('saccade') which is the transitions between eye-fixations and a variable ('time') which ranges for 0-1 for each trial. The transitions are classified into three different categories ('ver', 'hor' and 'diag'). Here is a script that will create a small example data set in python (one participant and two

How can I rotate gridline labels on a cartopy map?

六眼飞鱼酱① 提交于 2021-01-28 19:54:49
问题 I'm plotting a map using Stamen tiles inside a matplotlib figure like so: tiler=Stamen('terrain-background') mercator=tiler.crs ax3=fig.add_subplot(gs01[1,0], projection=ccrs.PlateCarree()) ax3.add_image(tiler,14) I then attempt to rotate the gridline tick labels like so: gl3=ax3.gridlines(crs=ccrs.PlateCarree(), draw_labels=True, linewidth=1., color='gray', alpha=0.75, linestyle='--') gl3.left_labels=False gl3.top_labels=False gl3.xlabel_style={'size':10., 'color':'gray', 'weight':'bold'}

installing doesn't resolve ModuleNotFoundError: No module named 'mpl_finance'

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-28 19:47:56
问题 The title says it all. Upon trying to run code related to this matplotlib candlestikck tutorial, I got the error: ModuleNotFoundError Traceback (most recent call last) <ipython-input-1-5aa61276079d> in <module> 2 import numpy as np 3 import yfinance ----> 4 from mpl_finance import candlestick_ohlc 5 import matplotlib.dates as mpl_dates 6 import matplotlib.pyplot as plt ModuleNotFoundError: No module named 'mpl_finance' So I installed it and restarted the kernel but still no dice. Next, I

Matplotlib magic in Jupyter notebook

时光怂恿深爱的人放手 提交于 2021-01-28 19:32:24
问题 When i am using the magic %matplotlib notebook it shows the follwing warning: Warning: Cannot change to a different GUI toolkit: notebook. Using gtk3 instead. What is the reason for this warning and how to get rid of it. 来源: https://stackoverflow.com/questions/61625435/matplotlib-magic-in-jupyter-notebook

How to use scientific notation in Pairplot (seaborn)

徘徊边缘 提交于 2021-01-28 19:08:13
问题 Is there a way to force scientific notation using Seaborn's Pairplot? I'm hoping for some consistency between plots (examples below). I've found suggestions for other seaborn plots, but have not successfully implemented anything with Pairplot. https://seaborn.pydata.org/generated/seaborn.pairplot.html Versions: seaborn 0.8.1 numpy 1.13.1 matplotlib 2.0.2 pandas 0.23.0 Current plot: import numpy as np import pandas as pd import seaborn as sns from scipy import stats import matplotlib.pyplot as

Matplotlib: Plot something new in an axis upon key press

人走茶凉 提交于 2021-01-28 19:06:46
问题 Each time the user presses a key on the keyboard, a new plot should be drawn. The example below uses just a random plot, in reality, I'll combine it with a statemachine that calls a different plot() function on each press. I have the short minimal code with a random plot: fig = plt.figure(1) ax1 = fig.add_subplot(111, aspect='equal') def plot(e): ax1.cla() ax1.plot(np.random.rand(10)) cid = fig.canvas.mpl_connect('key_press_event', plot) plt.show() Unfortunately, nothing happens. What is

what's the difference between plt.plot(), object.plot()

时间秒杀一切 提交于 2021-01-28 18:29:37
问题 I made a list > Book_of_Death_Count 1.0 49 2.0 73 3.0 97 4.0 27 5.0 61 Name: Book of Death, dtype: int64* When I type a = Book_of_Death_Count.plot(), b = plt.plot(Book_of_Death_Count) The result of the two is the same, but: a.set_xticks(np.arange(1,6)) works; b.set_xticks(np.arange(1,6)) doesn't work. What's the difference of these two code? 回答1: your "list" is a pandas DataFrame object. When you call Book_of_Death_Count.plot() you are using the function DataFrame.plot(), which returns (in

x-Axis ticks as dates

 ̄綄美尐妖づ 提交于 2021-01-28 14:36:06
问题 I have some data I would like to plot consisting of two columns, one being an amount count and the other column being the actually date recorded. When plotting this, since I have over 2000 dates, it makes more sense to not show every single date as a tick on the x -axis, otherwise it won't be readable. However, I am having a hard time making the dates show up on the x -axis with some kind of logic. I have tried using the in-built tick locators for matplotlib but it's not working somehow. Here