Questions tagged [trendline]

270 questions
79
votes
2 answers

How to add trendline to a scatter plot

How could I add a trendline to a dot graph drawn using matplotlib.scatter?
user3476791
  • 1,072
  • 1
  • 9
  • 14
34
votes
3 answers

How can I draw scatter trend line?

I want to draw a scatter trend line on matplot. How can I do that? Python import pandas as pd import matplotlib.pyplot as plt csv = pd.read_csv('/tmp/test.csv') data = csv[['fee', 'time']] x = data['fee'] y = data['time'] plt.scatter(x,…
zono
  • 8,366
  • 21
  • 75
  • 113
26
votes
1 answer

Draw a trend line using ggplot

I used ggplot2 to draw a trend line based on my data. Below is something I've done using spreadsheet. But I only want to show the trend line (black line as shown in upper plot) rather than all dots as number of observation is > 20,000. So I tried…
Sakura
  • 699
  • 1
  • 9
  • 14
25
votes
2 answers

How do I add different trend lines in R?

I know how to add a linear trend line using the lm and abline functions, but how do I add other trend lines, such as, logarithmic, exponential, and power trend lines?
grasingerm
  • 1,955
  • 2
  • 19
  • 22
19
votes
2 answers

Adding a simple lm trend line to a ggplot boxplot

When adding a linear model trend line to a boxplot using standard R graphics I use: boxplot(iris[,2]~iris[,1],col="LightBlue",main="Quartile1 (Rare)") modelQ1<-lm(iris[,2]~iris[,1]) abline(modelQ1,lwd=2) However, when using this in ggplot2: a <-…
JPD
  • 2,561
  • 5
  • 22
  • 26
16
votes
4 answers

Adding trendlines to existing chart Chart.js

from hours I've been looking for a solution to add trendlines to an existing chart built with Chart.js I think we can only add logarithmic trendline on Chart.js ? I don't want to draw a trendline from scratch, but add 2 trendlines based on existing…
Blue Agency
  • 608
  • 2
  • 7
  • 14
15
votes
1 answer

Adding a weighted least squares trendline in ggplot2

I am preparing a plot using ggplot2, and I want to add a trendline that is based on a weighted least squares estimation. In base graphics this can be done by sending a WLS model to abline: mod0 <- lm(ds$dMNP~ds$MNP) mod1 <- lm(ds$dMNP~ds$MNP,…
MEcon
  • 395
  • 4
  • 23
12
votes
2 answers

Python - calculating trendlines with errors

So I've got some data stored as two lists, and plotted them using plot(datasetx, datasety) Then I set a trendline trend = polyfit(datasetx, datasety) trendx = [] trendy = [] for a in range(datasetx[0], (datasetx[-1]+1)): trendx.append(a) …
Aaron Powell
  • 121
  • 1
  • 1
  • 3
6
votes
2 answers

Why am I getting the "ValueError: data type not inexact." while using polyfit function?

I am trying to plot a trendline for my data. However, I am getting the error ValueError: data type not inexact. Can someone explain why? my dataframe is Us_corr3; Here is my code: data5 = Us_corr3[['US GDP', 'US…
6
votes
1 answer

Extract slope of multiple trend lines from geom_smooth()

I am trying to plot multiple trend lines (every ten years) in a time series using ggplot. Here's the data: dat <- structure(list(YY = 1961:2010, a = c(98L, 76L, 83L, 89L, 120L, 107L, 83L, 83L, 92L, 104L, 98L, 91L, 81L, 69L, 86L, 76L, 85L, 86L,…
Lyndz
  • 347
  • 1
  • 13
  • 30
6
votes
1 answer

Automatic Trend Detection for Time Series / Signal Processing

What are the good algorithms to automatically detect trend or draw trend line (up trend, down trend, no trend) for time series data? Appreciate if you can point me to any good research paper or good library in python, R or Matlab. Ideally, the…
Joshua G
  • 239
  • 8
  • 12
6
votes
1 answer

How to get trendline equations in R

i have a series of data in form of time and temperature value. I want to generate a trendline and find the subsequent equation. This could be done in excel. but, how could i find equation of the trendline in R. abline function can be used to…
Jio
  • 578
  • 3
  • 8
  • 27
6
votes
1 answer

Add Regression Line ggplot for Only Certain Groups

I want to add trendlines to my ggplot, but only for the significant relations. Now geom_smooth or stat_smooth adds trendlines for each group, but I want to specify which groups get a trendline and which don't. Below an example of my…
user2170248
  • 63
  • 1
  • 1
  • 5
6
votes
1 answer

Calculate trendline and predict future results

I'm writing some analytics modules for the site I'm working on and I need to estimate the total views after the current hour. I have data for every minute up to the current minute, so if the time is 12:28, I will have an array that looks something…
Nick Brunt
  • 9,533
  • 10
  • 54
  • 83
5
votes
1 answer

Adding a trend line to a line plot

Apologies if this has already been asked but I can't find the answer anywhere. I want to add an overall trend line to a plt plot. Sample data: import pandas as pd data = pd.DataFrame({'year': [2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, …
prmlmu
  • 643
  • 1
  • 8
  • 16
1
2 3
17 18