0
import csv

a = csv.reader(open(DATA+'DataA.csv'))

for row in a:
   time = row[1]
   conversion = row[3]
   x_series = time
   y_series = conversion
   scatter_plot(zip(x_series,y_series))

I am attempting to create a scatter plot in Sage Notebook. I'm reading in the data in DataA.csv specifically rows 1 and 3. I want to create a scatter plot based on those pieces of data. Everything works except that a new scatter plot is created for each individual tuple instead of having all of them on one scatter plot. Any ideas of how I can fix this. Thanks in advance

NuNu
  • 667
  • 2
  • 12
  • 21

1 Answers1

0

You might want to try this.

import csv

a = csv.reader(open(DATA+'DataA.csv'))

G = Graphics()

for row in a:
   time = row[1]
   conversion = row[3]
   x_series = time
   y_series = conversion
   G += scatter_plot(zip(x_series,y_series))

G # this will show the plot

I don't have your data (or any data, actually) so I can't test it, but this should work fine. In Sage one adds plots, and then they show up as the default representation when G is given. You could ask the different scatter plots to have different colors, too...

Also, I prefer to use point or perhaps list_plot for this, but I guess it's a matter of preference.

kcrisman
  • 4,374
  • 20
  • 41