matplotlib

TypeError: unhashable type: 'numpy.ndarray' when trying to plot a DataFrame

强颜欢笑 提交于 2021-01-29 11:00:02
问题 I am new to Python and trying to create a plot graph from a DataFrame. I used the following piece of code: predictions= list() for the in range (10): predicted= StartARIMAForecasting(RegistrationRates, 5,1,0) predictions.append(predicted) RegistrationRates.append(predicted) data = {'Year':['2016','2017','2018','2019','2020','2021','2022','2023','2024','2025'], 'Registration Rate':predictions} resultdf = pd.DataFrame(data) print(resultdf) plt.xlabel('Year') plt.ylabel('Registration Rate') plt

How to show only 'x' amount of values on a graph in python

拟墨画扇 提交于 2021-01-29 10:57:24
问题 I am new to python and am carrying out some little projects along side watching tutorials to enable me to learn. I have recently been working with some APIs to collect data - I save this data in a CSV file and then open the CSV file to show the data as a graph. I want the graph to show the data LIVE , but in doing so I only want 10 values on the screen at once, so when the 11th value is plotted, the 1st is no longer visible unless the scrolling function is used to look back at it.. I have

How to draw an histogram with multiple categories in python

∥☆過路亽.° 提交于 2021-01-29 10:55:41
问题 I am a freshman in python, and I have a problem of how to draw a histogram in python. First of all, I have ten intervals that are divided evenly according to the length of flowers' petal, from min to max. Thus I can separate flowers into ten intervals based on petals. The number of flowers' kind is three, so I want to draw a histogram to describe the distribution of different kinds of flowers in different intervals(bins). And in the same bin, different flowers have different colors. I know

python assign different colors to bars in barplot

时间秒杀一切 提交于 2021-01-29 10:51:18
问题 How to assign different colors to the indices of a barh plot in pandas.DataFrame.plot ? I have a dataframe: group clicks_per_visit bookings_per_visit rev_per_visit test1 0.90 0.039 0.737 test2 0.87 0.034 0.726 I plot this using: temp3.plot(kind='barh',subplots=True,grid=True,figsize=(10,7)) to get this plot: I want the bars to have different colors to highlight the different test groups and I am also open to any other ideas or solutions to make a more 'fancy' visualization of this data. 回答1:

Simplest histogram with dates as x-axis in matplotlib

♀尐吖头ヾ 提交于 2021-01-29 10:25:48
问题 I have been trying to properly display a simple histogram with dates as x-axis and integers as y-axis. The example below happens to be a subplot (2 y-axis, 1 shared x-axis) but the problem is not there, it's rather the hist itself. import datetime import matplotlib matplotlib.use('agg') # server no need to display graphics import matplotlib.pyplot as plt # x-axis is 3 consecutive dates (days) now = datetime.datetime.now().date() x = [now, now + datetime.timedelta(days=1), now + datetime

getting value error when tried to make subplots for list of dataframe with matplotlib?

无人久伴 提交于 2021-01-29 10:23:40
问题 I have a list of dataframe that I want to render a line chart where making subplots for each dataframe. whereas two different dataframes in the list share same column structures. I want to make subplots (line chart) with minimal code possible. To do so, I referenced this post on SO but didn't get correct subplots. Below is my current approach for one dataframe: reproducible data : here is the minimal list of dataframe on gist file which concatenated from list of dataframes. each of dataframe

Inset_axes in polar coordinates

Deadly 提交于 2021-01-29 10:22:26
问题 I am using matplotlib.axes.Axes.inset_axes (https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.axes.Axes.inset_axes.html) to create an child axe of a an existing parent axe. How do I set it to polar coordinates ? I can not use this: Matplotlib inset polar plot as 'Axes' object has no property 'polar' . But inset_axes only returns Axes objects and not projections.polar.PolarAxes .. 回答1: From the comment of ImportanceOfBeingErnest: just use mpl_toolkits.axes_grid1.inset_locator.inset_axes()

Plot a perfect sphere with equal axes by parametric plot in Sympy

有些话、适合烂在心里 提交于 2021-01-29 10:10:20
问题 I would like to know how using plot3d_parametric_surface in Sympy we can plot a perfect sphere. By perfect I mean with equal axes. The result with this function has an oval shape! from sympy import * from sympy.plotting.plot import plot3d_parametric_surface from sympy.abc import theta , phi plot3d_parametric_surface(sin(phi)*cos(theta) , sin(phi)*sin(theta), cos(phi), (phi,0,pi),(theta,0,2*pi)) I tried to implement the answers in the matplotlib (equal unit length): with 'equal' aspect ratio z

pyplot catch windows 10 close windows event

 ̄綄美尐妖づ 提交于 2021-01-29 10:02:19
问题 how can I catch a close event from the windows close button in pyplot? the app is totally simple, but I want to stop plotting when the windows closer is clicked. plt.axis([0, 100, 0, 255, -5, 5]) plt.ion() plt.show() mainloop: plt.plot (whatever) 来源: https://stackoverflow.com/questions/58012313/pyplot-catch-windows-10-close-windows-event

Plotting times versus dates while skipping unwanted dates in Python

若如初见. 提交于 2021-01-29 10:00:50
问题 I want to make a program that monitors my 5000 meters progress. Inspired by this and this, I tried to make it work by combining some of the answers without any luck. from __future__ import division from matplotlib import pyplot as plt from matplotlib.ticker import FuncFormatter import matplotlib.dates as mdates import numpy as np import datetime as dt def equidate_ax(fig, ax, dates, fmt="%d.%m.%Y", label="Date"): N = len(dates) def format_date(index, pos): index = np.clip(int(index + 0.5), 0,