1

I need help plotting a dictionary, below is the data sample data set. I want to create a graph where x:y are (x,y) coordinates and title'x' would be the title of the graph.. I want to create individual graphs for each data set so one for title1':{x:y, x:y}, another one for title2:{x:y, x:y}....and so on.

Any help would be greatly appreciated. Thank you.

data = {'title1':{x:y, x:y},title2:{x:y,x:y,x:y},'title3':{x:y,x:y}....}

user3262210
  • 117
  • 1
  • 3
  • 7

1 Answers1

3

Creating sample data

In [3]: data = {'title1': {10:20, 4:10}, 'title2':{8:10, 9:20, 10:30}}

In [4]: data
Out[4]: {'title1': {4: 10, 10: 20}, 'title2': {8: 10, 9: 20, 10: 30}}

Iterating over data; creating x and y for each title and plotting it in new figure

In [5]: for title, data_dict in data.iteritems():
   ...:     x = data_dict.keys()
   ...:     y = data_dict.values()
   ...:     plt.figure()
   ...:     plt.plot(x,y)
   ...:     plt.title(title)

If you are not using IPython

plt.show()
Nipun Batra
  • 11,007
  • 11
  • 52
  • 77
  • Thank you so much Nipun, that's exactly what I needed help with. Good luck with your PhD. – user3262210 Feb 02 '14 at 17:56
  • Now I want to create a scatter plot with the data above.. What I want to do is plot the x and y data, and title becomes a legend(key on the map). so for example, lets start with title1, plot data associated with title1 in red( or any color), and make a key saying "title1" is that color, then plot2 and associated data with different color...and so on. Any suggestions? – user3262210 Feb 15 '14 at 20:02