Ask Your Question
1

date x-axis

asked 2013-12-02 06:57:22 +0100

yeKcim gravatar image

updated 2017-08-02 08:24:02 +0100

FrédéricC gravatar image

i need to plot a graph with bubbles : y-axis is a data, size is another one, in x i need to put date. How is it possible? What's the date format?

An exemple:

azerty=[(131118,43,16), (131118,43,10), (131118,46,8), (131118,43,15), (131118,38,19)]

dvorak=[(131119,7,25), (131120,6,14), (131120,7,26), (131121,7,28), (131121,8,26), (131122,9,18), (131123,9,26), (131123,10,23), (131123,11,17), (131124,12,14), (131124,12,15), (131124,11,25), (131124,12,12), (131124,12,15), (131124,12,20), (131125,9,17), (131125,10,18), (131125,13,9), (131126,13,6), (131126,13,11), (131126,13,8), (131127,13,12), (131127,12,16), (131127,15,12), (131127,16,10), (131127,14,9), (131127,13,19), (131127,13,14), (131127,12,14), (131127,13,11), (131127,13.2,17), (131127,12,19), (131127,11,22), (131128,13,9), (131128,15,17), (131128,15,14), (131128,14,18), (131128,14,12), (131128,13,22), (131128,13,13), (131128,14,11), (131128,15,16), (131129,14,14), (131129,13,16), (131129,14,9), (131129,14,15), (131130,17,12), (131130,18,8), (131130,13,18), (131130,16,26), (131130,16,14), (131130,16,15), (131201,14,9), (131201,16,12), (131201,15,13), (131201,14,14)]

P=text('words/minutes',(131150,5))

for x in azerty:
    P=P+circle((x[0],x[1]/10), x[2]/50, fill=True, edgecolor='blue', rgbcolor='blue', alpha=0.15)

for x in dvorak:
    P=P+circle((x[0],x[1]/10), x[2]/50, fill=True, edgecolor='green', rgbcolor='green', alpha=0.15)

P.plot()
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2013-12-02 10:44:22 +0100

kcrisman gravatar image

This is not necessarily a built-in in Sage. You can use matplotlib directly, but either way it looks like it might take a little extra time. See this stackoverflow question for a good example of how to proceed. The first thing I would suggest is to find a way to get your dates in Python datetime format. This stackoverflow question has the good suggestion of

sage: from dateutil import parser
sage: dt = parser.parse('131118')
sage: dt
datetime.datetime(2013, 11, 18, 0, 0)

In Sage the problem will be getting the circles to plot, because they will not accept datetime instances for coordinates. But you could use the parser above to create a tick formatter that would work - see here for one of many examples of such formatters. Sage should accept any matplotlib formatter properly in the tick_formatter argument to a plot, though again you may have to do something inventive to pass in just numbers rather than datetime instances.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-12-02 06:57:22 +0100

Seen: 573 times

Last updated: Dec 02 '13