Smooth line in facet plot
See original GitHub issueI’m trying to generate a faceted scatter plot with a line for the mean. This code works:
scatter = alt.Chart(data).mark_point().encode(
x="Position",
y="Value",
color="Cluster",
)
average = alt.Chart(data).mark_line(color="black").encode(
x="Position",
y="mean(Value)")
combined = scatter + average
combined.facet("Cluster")
However, as my data is sparse in some areas, I get very spiky lines that don’t capture the trend well. My quick fix is to round the values of data.Position for the line, which works okay, but I’m wondering if there’s a clever way to make use of statsmodel’s lowess smooth? I can only see doing that in pandas, adding a new column with smooths per cluster.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
ggplot2: Single smooth line for several line plots within facets
I want to plot multiple facets with several lines each. In every facet, for the set of line plots, I would like to...
Read more >Smooth lines with geom_smooth() + Facets with facet_wrap() | R
5 minutes is enough to create a professional-looking and ready for publication chart. In this video i show how to add smoothing lines...
Read more >Applying smooth to part of a facetted plot - Google Groups
I've got a facet_wrap() plot with ~42 facets. A few of those have only one data point per facet; the rest have between...
Read more >How to Plot a Smooth Line using GGPlot2 - Datanovia
This article descrbes how to easily plot smooth line using the ggplot2 R package. You will learn how to add: regression line, smooth...
Read more >How to Plot a Smooth Line using ggplot2 in R ? - GeeksforGeeks
We can plot a smooth line using the “loess” method of the geom_smooth() function. The only difference, in this case, is that we...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry, lost track of this. You are computing the running average of all points; I think you want to compute the running average within each group, which you can do by adding a
groupby
argument to your window transform.As I mentioned, I used the sort argument. For no sorting, however, can the average be higher than all data points.