File: test_style.py

package info (click to toggle)
plplot 5.15.0%2Bdfsg-19
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 31,312 kB
  • sloc: ansic: 79,707; xml: 28,583; cpp: 20,033; ada: 19,456; tcl: 12,081; f90: 11,431; ml: 7,276; java: 6,863; python: 6,792; sh: 3,274; perl: 828; lisp: 75; makefile: 50; sed: 34; fortran: 5
file content (105 lines) | stat: -rwxr-xr-x 3,275 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env python3
# Test of all line styles and box styles using pllegend.

# Append to effective python path so that can find plplot modules.
from plplot_python_start import *

import sys
import plplot as w
from numpy import *
from math import *

# Parse and process command line arguments
w.plparseopts(sys.argv, w.PL_PARSE_FULL)

xmin,xmax,ymin,ymax = (0., 1., 0., 1.)
# Initialize plplot
w.plinit()

# Set up legend arrays with the correct size, type.
# w.pllsty takes integers from 1 to 8.
nlegend = 8

opt_array = zeros(nlegend, "int")
text_colors = zeros(nlegend, "int")
text = zeros(nlegend, "S200")
box_colors = zeros(nlegend, "int")
box_patterns = zeros(nlegend, "int")
box_scales = zeros(nlegend)
box_line_widths = zeros(nlegend, "int")
line_colors = zeros(nlegend, "int")
line_styles = zeros(nlegend, "int")
line_widths = zeros(nlegend, "int")
symbol_colors = zeros(nlegend, "int")
symbol_scales = zeros(nlegend)
symbol_numbers = zeros(nlegend, "int")
symbols = zeros(nlegend, "S100")

# Only specify legend data that are required according to the
# value of opt_array for that entry.
opt_base = w.PL_LEGEND_BACKGROUND | w.PL_LEGEND_BOUNDING_BOX | w.PL_LEGEND_TEXT_LEFT

w.pladv(0)
w.plvpor(0.1, 0.9, 0.1, 0.9)
w.plwind(xmin, xmax, ymin, ymax)
text_scale = 0.90

# Set up line legend entries with various styles
for i in range(nlegend):
    opt_array[i] = w.PL_LEGEND_LINE
    text[i] = "%s %d" % ("Line Style",i+1)
    text_colors[i] = 2
    line_colors[i] = 2
    line_styles[i] = i+1
    line_widths[i] = 1

opt = opt_base
w.plscol0a( 15, 32, 32, 32, 0.70 )
(legend_width, legend_height) = \
    w.pllegend( opt, w.PL_POSITION_LEFT, 0., 0.,
              0.1, 15, 1, 1, 0, 0, opt_array, 1.0, text_scale, 2.0,
              0., text_colors, text,
              box_colors, box_patterns, box_scales, box_line_widths,
              line_colors, line_styles, line_widths,
              symbol_colors, symbol_scales, symbol_numbers, symbols )

# Set up legend arrays with the correct size, type.
# w.plpsty takes integers from 0 to 8.
nlegend = 9

opt_array = zeros(nlegend, "int")
text_colors = zeros(nlegend, "int")
text = zeros(nlegend, "S200")
box_colors = zeros(nlegend, "int")
box_patterns = zeros(nlegend, "int")
box_scales = zeros(nlegend)
box_line_widths = zeros(nlegend, "int")
line_colors = zeros(nlegend, "int")
line_styles = zeros(nlegend, "int")
line_widths = zeros(nlegend, "int")
symbol_colors = zeros(nlegend, "int")
symbol_scales = zeros(nlegend)
symbol_numbers = zeros(nlegend, "int")
symbols = zeros(nlegend, "S100")

# Set up box legend entries with various patterns.
for i in range(nlegend):
    opt_array[i] = w.PL_LEGEND_COLOR_BOX
    text[i] = "%s %d" % ("Box Pattern",i)
    text_colors[i] = 2
    box_colors[i] = 2
    box_patterns[i] = i
    box_scales[i] = 0.8
    box_line_widths[i] = 1

opt = opt_base
w.plscol0a( 15, 32, 32, 32, 0.70 )
(legend_width, legend_height) = \
    w.pllegend( opt, w.PL_POSITION_RIGHT, 0., 0.,
              0.1, 15, 1, 1, 0, 0, opt_array, 1.0, text_scale, 2.0,
              0., text_colors, text,
              box_colors, box_patterns, box_scales, box_line_widths,
              line_colors, line_styles, line_widths,
              symbol_colors, symbol_scales, symbol_numbers, symbols )

w.plend()