0

Is there a simple way or a package for creating binned scatterplots in python?

I have a scatterplot. I am fitting a local polynomial regression to the data using the package "localreg". I get multiple lines as output. I am searching for a 1 line output. In order to get this I want to used a binned scatterplot. Is there no easy way to do this ?

Chris
  • 433
  • 4
  • 17

2 Answers2

1

There is the hexabin plot in Matplotlib, if this suits your purpose. Here is an example. Here another example using seaborn.

gtancev
  • 243
  • 1
  • 10
1

You can first bin your arrays, do your fitting and then create your plot.

https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.binned_statistic.html

Can
  • 117
  • 3
  • How will you implement that exactly? I was thinking it should be possible to do it after I run the localreg? But how do I match my X and Y? – Chris Mar 27 '20 at 14:06
  • You might want to check this out: https://stackoverflow.com/q/26783719/13131172 binned_statistic returns bin numbers which you can use to slice your X array. – Can Mar 28 '20 at 19:40