Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def reset_colors():
lo_col_ind, hi_col_ind = ppgplot.pgqcol()
ppgplot.pgscir(lo_col_ind, hi_col_ind)
ppgplot.pgscr( 0, 0.00, 0.00, 0.00) # Black (background)
ppgplot.pgscr( 1, 1.00, 1.00, 1.00) # White (default)
ppgplot.pgscr( 2, 1.00, 0.00, 0.00) # Red
ppgplot.pgscr( 3, 0.00, 1.00, 0.00) # Green
ppgplot.pgscr( 4, 0.00, 0.00, 1.00) # Blue
ppgplot.pgscr( 5, 0.00, 1.00, 1.00) # Cyan (Green + Blue)
ppgplot.pgscr( 6, 1.00, 0.00, 1.00) # Magenta (Red + Blue)
ppgplot.pgscr( 7, 1.00, 1.00, 0.00) # Yellow (Red + Green)
ppgplot.pgscr( 8, 1.00, 0.50, 0.00) # Red + Yellow (Orange)
ppgplot.pgscr( 9, 0.50, 1.00, 0.00) # Green + Yellow
ppgplot.pgscr(10, 0.00, 1.00, 0.50) # Green + Cyan
ppgplot.pgscr(11, 0.00, 0.50, 1.00) # Blue + Cyan
ppgplot.pgscr(12, 0.50, 0.00, 1.00) # Blue + Magenta
ppgplot.pgscr(13, 1.00, 0.00, 0.50) # Red + Magenta
ppgplot.pgscr(14, 0.33, 0.33, 0.33) # Dark Gray
ppgplot.pgscr(15, 0.66, 0.66, 0.66) # Light Gray
for ci in range(16, hi_col_ind+1):
ppgplot.pgscr(ci, 0.00, 0.00, 0.00) # Black (background)
if noscale: rangey=[y.min(), y.max()]
else: rangey=scalerange(y)
# Prep the plotting device...
if (not ppgplot_dev_prep_ and setup):
prepplot(rangex, rangey, title, labx, laby, \
rangex2, rangey2, labx2, laby2, \
logx, logy, logx2, logy2, font, fontsize, \
id, aspect, ticks, panels, device=device)
# Choose the line color
if isstr(color):
ppgplot.pgsci(ppgplot_colors_[color])
else:
ppgplot.pgsci(color)
# Plot symbols (and errors) if requested
if not symbol is None:
ppgplot.pgpt(x, y, symbol)
# Error bars
if errx is not None:
if not logx:
errx = Num.asarray(errx)
ppgplot.pgerrx(x+errx, x-errx, y, 1.0)
else:
errx = 10.0**Num.asarray(errx)
ppgplot.pgerrx(Num.log10(10.0**x + errx),
Num.log10(10.0**x - errx), y, 1.0)
if erry is not None:
if not logy:
erry = Num.asarray(erry)
ppgplot.pgerry(x, y+erry, y-erry, 1.0)
else:
erry = 10.0**Num.asarray(erry)
ppgplot.pgerry(x, Num.log10(10.0**y + erry),
else: otheryaxis=1
# Open the plot device
if (not ppgplot_dev_open_):
ppgplot.pgopen(device)
# Let the routines know that we already have a device open
ppgplot_dev_open_ = 1
# Set the aspect ratio
ppgplot.pgpap(0.0, aspect)
if (panels != [1,1]):
# Set the number of panels
ppgplot.pgsubp(panels[0], panels[1])
ppgplot.pgpage()
# Choose the font
ppgplot.pgscf(font)
# Choose the font size
ppgplot.pgsch(fontsize)
# Choose the font size
ppgplot.pgslw(ppgplot_linewidth_)
# Plot the 2nd axis if needed first
if otherxaxis or otheryaxis:
ppgplot.pgvstd()
ppgplot.pgswin(rangex2[0], rangex2[1], rangey2[0], rangey2[1])
# Decide how the axes will be drawn
if ticks=='in': env = "CMST"
else: env = "CMSTI"
if logx2: lxenv='L'
else: lxenv=''
if logy2: lyenv='L'
else: lyenv=''
if otherxaxis and otheryaxis:
ppgplot.pgbox(env+lxenv, 0.0, 0, env+lyenv, 0.0, 0)
elif otheryaxis:
def closeplot():
"""
closeplot():
Close the currently open plotting device
"""
global ppgplot_dev_open_, ppgplot_dev_prep_
ppgplot.pgend()
ppgplot_dev_open_ = 0
ppgplot_dev_prep_ = 0
if isstr(color):
ppgplot.pgsci(ppgplot_colors_[color])
else:
ppgplot.pgsci(color)
# Construct the contours
ppgplot.pgcont_s(z, len(contours), contours, rangex[0], \
rangey[0], rangex[1], rangey[1])
# Label the contours if requested
if labels is not None:
# Choose the line color for the contourlines
if isstr(labels):
ppgplot.pgsci(ppgplot_colors_[labels])
else:
ppgplot.pgsci(labels)
for i in range(len(contours)):
ppgplot.pgconl_s(z, contours[i], str(contours[i]),
labelint, labelmin)
Num.maximum.reduce(Num.ravel(z))]
# Prep the plotting device...
if (not ppgplot_dev_prep_):
prepplot(rangex, rangey, title, labx, laby, \
rangex2, rangey2, labx2, laby2, logx, logy, \
logx2, logy2, font, fontsize, id, aspect, \
ticks, panels, device=device)
if image is not None:
# Set the color indices and the color table
lo_col_ind, hi_col_ind = ppgplot.pgqcol()
lo_col_ind = lo_col_ind + 2
ppgplot.pgscir(lo_col_ind, hi_col_ind)
pgpalette.setpalette(image)
ppgplot.pgctab(pgpalette.l,pgpalette.r,pgpalette.g,pgpalette.b)
# Construct the image
ppgplot.pgimag_s(z, 0.0, 0.0, rangex[0], rangey[0], \
rangex[1], rangey[1])
reset_colors()
if contours is not None:
contours = Num.asarray(contours)
# Choose the line style
ppgplot.pgsls(line)
# Choose the line width
ppgplot.pgslw(width)
# Choose the line color for the contourlines
if isstr(color):
ppgplot.pgsci(ppgplot_colors_[color])
else:
ppgplot.pgsci(color)
# Construct the contours
ppgplot.pgcont_s(z, len(contours), contours, rangex[0], \
rangey[0], rangex[1], rangey[1])
# Set the aspect ratio
ppgplot.pgpap(0.0, aspect)
if (panels != [1,1]):
# Set the number of panels
ppgplot.pgsubp(panels[0], panels[1])
ppgplot.pgpage()
# Choose the font
ppgplot.pgscf(font)
# Choose the font size
ppgplot.pgsch(fontsize)
# Choose the font size
ppgplot.pgslw(ppgplot_linewidth_)
# Plot the 2nd axis if needed first
if otherxaxis or otheryaxis:
ppgplot.pgvstd()
ppgplot.pgswin(rangex2[0], rangex2[1], rangey2[0], rangey2[1])
# Decide how the axes will be drawn
if ticks=='in': env = "CMST"
else: env = "CMSTI"
if logx2: lxenv='L'
else: lxenv=''
if logy2: lyenv='L'
else: lyenv=''
if otherxaxis and otheryaxis:
ppgplot.pgbox(env+lxenv, 0.0, 0, env+lyenv, 0.0, 0)
elif otheryaxis:
ppgplot.pgbox("", 0.0, 0, env+lyenv, 0.0, 0)
else:
ppgplot.pgbox(env+lxenv, 0.0, 0, "", 0.0, 0)
# Now setup the primary axis
ppgplot.pgvstd()
ppgplot.pgswin(rangex[0], rangex[1], rangey[0], rangey[1])
# Error bars
if errx is not None:
if not logx:
errx = Num.asarray(errx)
ppgplot.pgerrx(x+errx, x-errx, y, 1.0)
else:
errx = 10.0**Num.asarray(errx)
ppgplot.pgerrx(Num.log10(10.0**x + errx),
Num.log10(10.0**x - errx), y, 1.0)
if erry is not None:
if not logy:
erry = Num.asarray(erry)
ppgplot.pgerry(x, y+erry, y-erry, 1.0)
else:
erry = 10.0**Num.asarray(erry)
ppgplot.pgerry(x, Num.log10(10.0**y + erry),
Num.log10(10.0**y - erry), 1.0)
# Plot connecting lines if requested
if not line is None:
# Choose the line style
ppgplot.pgsls(line)
# Choose the line width
ppgplot.pgslw(width)
ppgplot.pgline(x, y)
# scalerange() values of the 1st Y axis.
if rangex2 is None:
rangex2=rangex
otherxaxis=0
else: otherxaxis=1
if rangey2 is None:
rangey2=rangey
otheryaxis=0
else: otheryaxis=1
# Open the plot device
if (not ppgplot_dev_open_):
ppgplot.pgopen(device)
# Let the routines know that we already have a device open
ppgplot_dev_open_ = 1
# Set the aspect ratio
ppgplot.pgpap(0.0, aspect)
if (panels != [1,1]):
# Set the number of panels
ppgplot.pgsubp(panels[0], panels[1])
ppgplot.pgpage()
# Choose the font
ppgplot.pgscf(font)
# Choose the font size
ppgplot.pgsch(fontsize)
# Choose the font size
ppgplot.pgslw(ppgplot_linewidth_)
# Plot the 2nd axis if needed first
if otherxaxis or otheryaxis:
ppgplot.pgvstd()
ppgplot.pgswin(rangex2[0], rangex2[1], rangey2[0], rangey2[1])
# Decide how the axes will be drawn
if ticks=='in': env = "CMST"