matplotlib

How to create a historical timeline with Python

房东的猫 提交于 2021-02-18 18:20:26
问题 So I've seen a few answers on here that helped a bit, but my dataset is larger than the ones that have been answered previously. To give a sense of what I'm working with, here's a link to the full dataset. I've included a picture of one attempted solution, which was found at this link: . The issue is that 1. This is difficult to read and 2. I don't know how to flatten it out so that it looks like a traditional timeline. The issue becomes more apparent when I try and work with larger segments,

How to create a historical timeline with Python

冷暖自知 提交于 2021-02-18 18:20:07
问题 So I've seen a few answers on here that helped a bit, but my dataset is larger than the ones that have been answered previously. To give a sense of what I'm working with, here's a link to the full dataset. I've included a picture of one attempted solution, which was found at this link: . The issue is that 1. This is difficult to read and 2. I don't know how to flatten it out so that it looks like a traditional timeline. The issue becomes more apparent when I try and work with larger segments,

Pygal subplot (several figures)

左心房为你撑大大i 提交于 2021-02-18 17:34:43
问题 I want to create a dashboard using Pygal on python 2.7 (Several plots in the same window) but the later doesn't have the subplot function, Is there a solution, without using bokeh or plotly? Example on Matplotlib: fig, axes = plt.subplots(ncols=4, nrows=5, figsize=(35,20)) for ax in axes.flatten(): ax.plot([2,3,5,1]) plt.show() Is there something like this on Pygal? 回答1: # -*- coding: utf-8 -*- import pygal list2=["A","B","C","D"] liste_A=[10,20,30,40] liste_B=[100,10,50,20] html_file=open(

Fast plotting data in python

℡╲_俬逩灬. 提交于 2021-02-18 17:16:08
问题 I'm trying to plot data from mpu6050 imu with arduino. MPU6050 sends data faster than plot. Arduino code gives 6 data which are yaw, pitch, roll, ax,ay and az from serial port. I need suggestions for fast plot . Python Code: import serial import matplotlib.pyplot as plt #import matplotlib library from drawnow import * ser = serial.Serial('COM9', 115200) yaw = 0.0 pitch =0.0 roll =0.0 ax =0.0 ay =0.0 az =0.0 o_yaw= [0] o_pitch= [0] o_roll= [0] o_ax= [0] o_ay= [0] o_az= [0] plt.ion() cnt=0 def

curve fitting zipf distribution matplotlib python

好久不见. 提交于 2021-02-18 17:11:13
问题 I tried to fit the following plot(red dot) with zipf distribution in python, F~x^(-a) I just simply chose a=0.56, and plot y = x^(-0.56) and I got the curve as follow: which is obviously wrong, don't know how I can do the curve fit 回答1: Not sure what you are exactly looking for, but if you want to fit a model (function) to data, use scipy.optimize.curve_fit : from scipy.optimize import curve_fit from scipy.special import zetac def f(x, a): return (x**-a)/zetac(a) result = curve_fit(f, x, y,

curve fitting zipf distribution matplotlib python

こ雲淡風輕ζ 提交于 2021-02-18 17:10:08
问题 I tried to fit the following plot(red dot) with zipf distribution in python, F~x^(-a) I just simply chose a=0.56, and plot y = x^(-0.56) and I got the curve as follow: which is obviously wrong, don't know how I can do the curve fit 回答1: Not sure what you are exactly looking for, but if you want to fit a model (function) to data, use scipy.optimize.curve_fit : from scipy.optimize import curve_fit from scipy.special import zetac def f(x, a): return (x**-a)/zetac(a) result = curve_fit(f, x, y,

Why don't I need “%matplotlib inline” in my jupyter notebook?

﹥>﹥吖頭↗ 提交于 2021-02-18 14:00:53
问题 I am just trying to understand why my jupyter installation does not require me to run '%matplotlib inline' (which, according to everything I've read, I should have to run that to get my plots inline in my jupyter notebook). But the fact is, my matplotlib plots appear inline in my notebook whether I run '%matplotlib inline' or not. I am running an anaconda install of jupyter on ubuntu under WSL, using chrome as the client to my notebook server. jupyter --version 4.4.0 and jupyter-notebook -

Matplotlib normalize colorbar (Python)

孤街醉人 提交于 2021-02-18 12:45:39
问题 I'm trying to plot a contourf-plot using matplotlib (and numpy of course). And it works, it plots what it should plot, but unfortunatelly I cannot set the colorbar range. The problem is that I have a plenty of plots and need all of them to have the same colorbar (same min and max, same colors). I copy&past-ed almost every code snippet I found on the internet, but without success. My code so far: import numpy as np; import matplotlib as mpl; import matplotlib.pyplot as plt; [...] plotFreq,

Marking specific dates when visualizing a time series

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-18 12:14:30
问题 I have a time series that has a few years' worth of data, for example this: ts = pd.Series(np.random.randn(1000), index=pd.date_range('1/1/2000', periods=1000)) ts = ts.cumsum() ts.plot() I also have two extra arrays: let's call the first dates = [pd.datetime("2000-12-01"), pd.datetime("2001-01-03")] And the second labels = ["My birthday", "My dad's birthday"] labels[i] contains the label for dates[i]. What I'd like to do is to display them in the time series graph so that they can be

Matplotlib in py2exe — ImportError: cannot import name dist (File “distutils\__init__.pyc”)

落爺英雄遲暮 提交于 2021-02-18 12:09:45
问题 Matplotlib working in this app perfectly.. but not working in build for some reason. Why? I'll gladly take any advice that can help me. .exe.log : Traceback (most recent call last): File "main.py", line 3, in <module> File "zipextimporter.pyc", line 82, in load_module File "matplotlib\__init__.pyc", line 103, in <module> File "zipextimporter.pyc", line 82, in load_module File "distutils\__init__.pyc", line 25, in <module> ImportError: cannot import name dist main.py is a script that I'm