Filled Area

../../../../_images/filled_area.png
 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
# Plot filled area
# This example creates a simple plot with a line and a fill area.

# Generate some dummy data.
position = numpy.linspace(0, 1, 24) * Angstrom
energy = (numpy.linspace(-1, 1, 24) + 0.2 * numpy.random.rand(24)) * eV
energy_error = numpy.linspace(0.2, 0.5, 24) * eV

# Create a model.
model = Plot.PlotModel(Angstrom, eV)
model.title().setText('Plot Fills')
model.legend().setVisible(True)
model.xAxis().setLabel('Length')
model.yAxis().setLabel('Energy')

# Create line.
line = Plot.Line(position, energy)
line.setColor('mediumpurple')
line.setLabel('Line')
line.setLineWidth(2)
model.addItem(line)

# Create and add fill area.
fill = Plot.HorizontalFill(position, energy - energy_error, energy + energy_error)
fill.setLabel('Filled')
fill.setColor('mediumpurple')
fill.setAlpha(0.5)
model.addItem(fill)

# Autoscale.
model.setLimits()

# Show the plot for interactive editing.
Plot.show(model)

# Save the plot (can also be saved to svg, pdf, jpeg or hdf5).
Plot.save(model, 'filled.png')

References: Plot.HorizontalFill, Plot.PlotModel, Plot.save, Plot.show, Plot.Line.

↩ Go back to Plots