Example #1
0
from gram import Plot

xx1 = [2, 4, 7, 3, 9]
yy1 = [4, 5, 1, 7, 4]
gp = Plot()
gp.contentSizeX = 2
gp.contentSizeY = 1.5
gp.baseName = 'textInPlot'
gp.scatter(xx1, yy1, plotMark='asterisk')
c = gp.xYText(7, 1.2, r'$\Downarrow$')
c.anchor = 'south'
c = gp.xYText(3.3, 7, r'$\leftarrow$\ Ignore this point')
c.textSize = 'tiny'
c.anchor = 'west'
gp.xAxis.title = None
gp.yAxis.title = None
gp.png()
# gp.svg()  # looks bad, the latex text is not rendered
Example #2
0
        h = 0.0005 * j
        h += 0.5
        j += 1
        pt = func.polar2square([r, h])
        xx.append(pt[0])
        yy.append(pt[1])
    xxx.append(xx)
    yyy.append(yy)

from gram import Plot
gp = Plot()
gp.baseName = 'spiral'
for rev in range(8):
    xx = xxx[rev]
    yy = yyy[rev]
    g = gp.line(xx, yy, smooth=True)
    g.lineStyle = gp.goodLineStyles[rev]
    print g.lineStyle
gp.contentSizeX = 4.5
gp.contentSizeY = gp.contentSizeX
gp.xAxis.title = None
gp.yAxis.title = None
gp.yAxis.styles.remove('ticks')
gp.xAxis.styles.remove('ticks')
gp.frameT = None
gp.frameB = None
gp.frameL = None
gp.frameR = None
gp.png()
gp.svg()
Example #3
0
g.colour = 'blue'
g = gp.line(yy1b, xx1)
g.color = 'blue'

g = gp.line([-4, 4], [-4, 4])
g.color = 'red'
g = gp.line([-4, 4], [4, -4])
g.colour = 'red'

myTextSize = 'tiny'
l1 = r'$y^2 + x^2 = 1$'
g = gp.xYText(-2, 2.5, l1)
g.anchor = 'west'
g.textSize = myTextSize

l1 = r'$x^2 - y^2 = 1$'
g = gp.xYText(1.5, 1., l1)
g.anchor = 'west'
g.textSize = myTextSize

howBig = 3.5
gp.contentSizeX = howBig
gp.contentSizeY = howBig
gp.xAxis.title = None
gp.yAxis.title = None
gp.yAxis.sig = '%.1f'
gp.baseName = 'hyperbolas'
gp.png()
#gp.svg()

Example #4
0
import math
from gram import Plot
gp = Plot()
gp.baseName = 'xyText'
# make an invisible plot
xx = list(range(17))
yy = [math.sin(x) for x in xx]
c = gp.line(xx, yy)
c.colour = 'green'
# make some text at x,y
for i in range(len(xx)):
    c = gp.xYText(xx[i],yy[i],'%i' % i)
    c.shape = 'circle'
    c.fill = 'red!10'
    c.rotate = i * 15
gp.contentSizeX = 5.
# remove the axes and frame
gp.yAxis.title = None 
gp.xAxis.title = None 
gp.yAxis.styles.remove('ticks') 
gp.xAxis.styles.remove('ticks')
gp.frameT = None 
gp.frameB = None 
gp.frameL = None 
gp.frameR = None 
gp.png() 
gp.svg()  # squares, not circles.
Example #5
0
        h += 0.5
        j += 1
        pt = func.polar2square([r,h])
        xx.append(pt[0])
        yy.append(pt[1])
    xxx.append(xx)
    yyy.append(yy)
    
from gram import Plot
gp = Plot()
gp.baseName = 'spiral'
for rev in range(8):
    xx = xxx[rev]
    yy = yyy[rev]
    g = gp.line(xx,yy,smooth=True)
    g.lineStyle = gp.goodLineStyles[rev]
    print(g.lineStyle)
gp.contentSizeX = 4.5
gp.contentSizeY = gp.contentSizeX
gp.xAxis.title = None
gp.yAxis.title = None
gp.yAxis.styles.remove('ticks') 
gp.xAxis.styles.remove('ticks') 
gp.frameT = None
gp.frameB = None
gp.frameL = None
gp.frameR = None
gp.png()
gp.svg()

Example #6
0
import random
from gram import Plot
plotmarks = ['o', 'square',
             'triangle', 'diamond']
gg = []
for i in [0,1]:
    for j in [0,1]:
        xx1 = []
        yy1 = []
        for k in range(23):
            xx1.append(random.random())
            yy1.append(random.random())

        gp = Plot()
        gp.contentSizeX = 2.5
        gp.contentSizeY = 2.
        thePlotMark = plotmarks[(2 * i) +j]
        c = gp.scatter(xx1, yy1,
                       plotMark=thePlotMark)
        gp.minXToShow = 0.0
        gp.minYToShow = 0.0
        gp.maxXToShow = 1.0
        gp.maxYToShow = 1.0
        theText = '[%i.%i]' % (i, j)
        c = gp.xYText(0.5, 0.5, theText)
        c.colour = 'blue'

        if i == 0:
            gp.xAxis.title = None
            gp.xAxis.styles.remove('ticks') 
        else:
Example #7
0
g.colour = 'blue'
g = gp.line(yy1b, xx1)
g.color = 'blue'

g = gp.line([-4, 4], [-4, 4])
g.color = 'red'
g = gp.line([-4, 4], [4, -4])
g.colour = 'red'

myTextSize = 'tiny'
l1 = r'$y^2 + x^2 = 1$'
g = gp.xYText(-2, 2.5, l1)
g.anchor = 'west'
g.textSize = myTextSize

l1 = r'$x^2 - y^2 = 1$'
g = gp.xYText(1.5, 1., l1)
g.anchor = 'west'
g.textSize = myTextSize

howBig = 3.5
gp.contentSizeX = howBig
gp.contentSizeY = howBig
gp.xAxis.title = None
gp.yAxis.title = None
gp.yAxis.sig = '%.1f'
gp.baseName = 'hyperbolas'
gp.png()
gp.svg() # does not work, due to latex math