plot

Fitted regression line parameters in python

Fitted regression line parameters in python Question: How can I get the intercept and the slope of the fitted regression line in qqplot? Here’s a small working example, where I want the parameters of the red regression line: import statsmodels.api as sm import scipy.stats as stats import numpy as np np.random.seed(100) a = np.random.normal(0, 4, …

Total answers: 2

Python to add data label on linechart from Matplotlib and Pandas GroupBy

Python to add data label on linechart from Matplotlib and Pandas GroupBy Question: I am hoping to add data labels to a line chart produced by Matplotlib from Pandas GroupBy. import matplotlib.pyplot as plt import pandas as pd from io import StringIO csvfile = StringIO( """ Name Year – Month Score Mike 2022-09 192 Mike …

Total answers: 2

How to plot line chart with lines from index?

How to plot line chart with lines from index? Question: I have a dataframe I’ve already aggregated averages for, which are the columns nr_1, nr_2, etc. They are grouped by a bin, which is also now the index. How do I create a line plot where the lines are the index, and the X axis …

Total answers: 1

How to specify x and y in the dataframe groupby plot

How to specify x and y in the dataframe groupby plot Question: I have a dataframe which contains essentially 3 columns(I have many columns but the main idea is presented here): df["Label","Data1","Data2"] df = pd.DataFrame({‘Label’: [1, 1, 1, 2, 2, 3, 3, 3, 4, 4], ‘Data1’: [0.1, 0.01, 0.15, 0.3, 0.35, 0.38, 0.44, 0.45, 0.8, …

Total answers: 1

3D Scatterplot in Python using strings instead of values

3D Scatterplot in Python using strings instead of values Question: I need to make a 3d plot, where the axes will have labels in string instead of values. So I have 3 lists, the same size, and I need to have the first element of the first list to be my X coordinate, the first …

Total answers: 1

How to connect two points of two different plots using pyplot?

How to connect two points of two different plots using pyplot? Question: I have the following code to plot two plots: x = range(mov_x_1.shape[0]) plt.plot(x,mov_x_1) plt.plot(x, mov_x_2) plt.show() getting the following result Now I have a variable path = [(0, 0), (1, 1), (2, 1), (3, 1), (4, 2), (5, 3), (6, 4), (6, 5), …

Total answers: 1

Pandas bar plot ignores the xlim parameter

Pandas bar plot ignores the xlim parameter Question: I would like to only make a plot with only the year between 1990 and 2000. import random import pandas as pd df = pd.DataFrame({‘year’:range(1950,2020), ‘value’:[random.randint(100, 1000) for x in range(70)]}) df.plot(kind = ‘bar’, x = ‘year’, y =’value’, xlim = (1990,2000)) Whatever I set the value …

Total answers: 1

X and Y-axises is duplicated when major_formatter is set

X and Y-axises is duplicated when major_formatter is set Question: I have a code to plot an empty graph: from datetime import datetime, timedelta from matplotlib import pyplot, dates pyplot.yticks([0,1,2,3,4]) ts_start = datetime.now() – timedelta(hours=1) ts_end = datetime.now() delta = timedelta(minutes=10) x_dates = dates.drange(ts_start, ts_end, delta=delta) pyplot.xlim(x_dates[0], x_dates[-1]) # fmt = dates.DateFormatter(‘%Y-%m-%d %H:%M:%S’) # pyplot.axes().xaxis.set_major_formatter(fmt) …

Total answers: 1