-3

I have large (~1 million) data set that looks something like this...

Age    Wavelength    Luminosity

1      96            100
1      97            150
1      98            100
2      96.5          90
2      97            160
2      97.5          120
...

I have it in a dataframe currently and want to plot wavelength vs Luminosity for all age groups. How do i get plots for each age on one graph?

Cmf55
  • 61
  • 1
  • 8
  • This looks like not a stackoverflow question. what about posting your question to http://programmers.stackexchange.com/? – Andrés Oviedo Jul 19 '16 at 13:55
  • 1
    @Andrés when referring other sites, it is often helpful to point that [cross-posting is frowned upon](http://meta.stackexchange.com/tags/cross-posting/info) – gnat Jul 19 '16 at 13:59
  • 2
    How is this even remotely on-topic on Programmers? – Robert Harvey Jul 19 '16 at 14:06

1 Answers1

0

You can use pandas.core.groupby.DataFrameGroupBy.plot

In[1]: import pandas as pd

In[2]: import numpy as np

In[3]: dataset = pd.DataFrame({"Age": np.random.random_integers(1, 5, 100), "Wavelength": np.random.uniform(90, 100, 100), "Luminosity": np.random.random_integers(5, 15, 100) * 10})

In[4]: dataset.groupby("Age").plot(x="Wavelength", y="Luminosity", kind="scatter")
Out[4]: 
Age
1    Axes(0.125,0.1;0.775x0.8)
2    Axes(0.125,0.1;0.775x0.8)
3    Axes(0.125,0.1;0.775x0.8)
4    Axes(0.125,0.1;0.775x0.8)
5    Axes(0.125,0.1;0.775x0.8)
dtype: object
Kapil Sharma
  • 1,412
  • 1
  • 15
  • 19
  • Thank you! Is there a way to get all of these onto one graph? – Cmf55 Jul 05 '16 at 09:57
  • The `plot` function returns an `matplotlib` `AxesSubplot` object. So you could work with `matplotlib` subplot grid and this axis object. I haven't tried it though. – Kapil Sharma Jul 05 '16 at 16:12