0

I am tying to create a bar chart with text using the following tuple as the data in the tuple there are groups of lists that have a number which is number of cars followed by date and time. I am completely lost on how to iterate from the tuple into a graph successfully. Can someone please help? Here is the tuple:

data = [
(2,"12/21/2017 21:30"),

(8,"12/21/2017 22:30"),

(1,"12/22/2017 00:30"),

(1,"12/22/2017 01:30"),

(1,"12/22/2017 03:30"),

(2,"12/22/2017 05:30"),

(8,"12/22/2017 06:30"),

(3,"12/22/2017 07:30")

]
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • 5
    I don't think we need to see all the data. Remove all but just a few examples to make your question easier to read. – 001 Jun 11 '18 at 18:18
  • 2
    In addition to cleaning up your sample data, you need to show some sort of effort and produce a MCVE. Simply saying you don't know and asking for us to do the work for you is wrong. –  Jun 11 '18 at 18:21

1 Answers1

0

I think you want to unzip the data first so that they can be plotted using standard libraries.

Using this method first: Transpose/Unzip Function (inverse of zip)?

In Python2x:

y,x = zip(*data)

In Python3x (since zip returns a zip object):

y,x = [ii for ii in zip(*data)]

Then you can use something like pylab to construct your barchart where you can do your own formatting/tweaking.

pylab.bar(x,y)

enter image description here

edfreeburg
  • 25
  • 6