2
Draw multiple side-by-side plots
4
Draws a static plot of bessel functions, oriented vertically, side-by-side.
6
You can experiment with using different orientations of containers or plots
7
by modifying lines 26 and 27.
10
# Major library imports
11
from numpy import arange
12
from scipy.special import jn
14
from chaco.example_support import COLOR_PALETTE
16
# Enthought library imports
17
from enable.api import Component, ComponentEditor
18
from traits.api import HasTraits, Instance
19
from traitsui.api import Item, Group, View
20
from chaco.api import PlotLabel, VPlotContainer, HPlotContainer, \
23
# ======================================================================
24
# Change one or both of these to experiment with different orientations
25
# of the plot containers and the lines within each plot:
26
container_class = HPlotContainer # HPlotContainer or VPlotContainer
27
plot_orientation = 'v' # 'v' or 'h'
28
# ======================================================================
30
#===============================================================================
31
# # Create the Chaco plot.
32
#===============================================================================
33
def _create_plot_component():
37
x = arange(low, high, (high-low)/numpoints)
38
container = container_class(resizable = "hv", bgcolor="lightgray",
39
fill_padding=True, padding = 10)
41
# Plot some bessel functions
45
plot = create_line_plot((x,y), color=tuple(COLOR_PALETTE[i]), width=2.0,
46
orientation=plot_orientation)
47
plot.origin_axis_visible = True
48
plot.origin = "top left"
49
plot.padding_left = 10
50
plot.padding_right = 10
51
plot.border_visible = True
52
plot.bgcolor = "white"
53
if value_range is None:
54
value_range = plot.value_mapper.range
56
plot.value_range = value_range
57
value_range.add(plot.value)
59
plot.line_style = "dash"
62
container.padding_top = 50
63
container.overlays.append(PlotLabel("Bessel Functions in a Strip Plot",
66
overlay_position = "top"))
70
#===============================================================================
71
# Attributes to use for the plot view.
73
title="Vertical Line Plot"
75
#===============================================================================
76
# # Demo class that is used by the demo.py application.
77
#===============================================================================
78
class Demo(HasTraits):
79
plot = Instance(Component)
83
Item('plot', editor=ComponentEditor(size=size),
85
orientation = "vertical"),
86
resizable=True, title=title,
87
width=size[0], height=size[1]
90
def _plot_default(self):
91
return _create_plot_component()
95
if __name__ == "__main__":
96
demo.configure_traits()