We’ve got 4 significant updates in the 2.4 release:
For a quick reference of all examples in this announcement, check out this page in the gallery.
It’s been a bit difficult to manually specify colors in VCS; you have to memorize the index of colors you want out of the 255-color colormap, and have “magic” numbers sprinkled throughout your code wherever you reference a color. That system will remain in place (backwards compatibility is very important to us), but @doutriaux1 majorly reworked the color logic throughout VCS to make it substantially more user-friendly.
We now support X11 color names, RGBA, and RGB color assignment, which you can check out in the gallery.
Colormaps now use RGBA values as well!
Also, you can now use any matplotlib colormap!
At long last, we’ve closed issue #541 (Thanks for being patient, @jypeter!). Patterns and hatches are available for boxfill
s, isofill
s, meshfill
s, and fillarea
s.
fillarea
provides a simple way to introduce the concepts of patterns and hatches. The fillarea
object is a secondary graphics method, for those who aren’t familiar with it. It allows you to provide a series of points, and will create a filled area styled to your specifications.
There are three attributes that are relevant to Patterns and Hatches for fillarea
s.
style
solid
pattern
hatch
color
attribute of the fillareaindex
opacity
For primary graphics methods (Boxfill, Isofill, Meshfill), you use these attributes:
fillareastyle
style
above. Accepts hatch
(colored pattern), pattern
(black pattern), or solid
(no pattern, the default)fillareaindices
index
in the examples above. Accepts a list of integers between 1 and 20; refer to the chart above to know what patterns to expect for what index. You provide one index per level in your plot.fillareaopacity
opacity
in the examples above. Accepts a list of floats between 1 and 100. You provide one opacity value per level in your plot.However, if you’re going to use these, you’re also going to have to specify levels for the graphics method. Normally, the graphics method will determine levels based off of the values at the current time slice; when you want to control the appearance of those levels, you need to specify them manually. For clt
, we can just use a range from 0 to 100 at increments of 20.
Important Note:
levels
describes the bounds of ranges, whereasfillareaindices
andfillareacolors
both describe the ranges themselves. You need one more level than indices or colors.
We’ve done some touch-up to the process of sizing your canvas in VCS.
import vcs
canvas = vcs.init()
canvas.open()
This should create a window that is a reasonable size for your monitor.
If you want a specific size, you can pass in arguments to either vcs.init()
or canvas.open()
, like so:
import vcs
canvas1 = vcs.init(geometry={"width":1200, "height":800})
canvas1.open()
canvas2 = vcs.init(geometry=(1200, 800))
canvas2.open()
canvas3 = vcs.init()
canvas3.open(width=1200, height=800)
Widths and heights passed to canvas.open()
will override the geometry passed in to vcs.init()
.
If you call canvas.png
with only a filename as an argument, you’ll get your output in the same dimensions as the canvas.
import vcs
canvas = vcs.init(geometry=(300, 200))
canvas.open()
canvas.png("test")
But if you want to size the output to a different size, you can pass in height
and width
keyword arguments to the canvas.png
function.
import vcs
canvas = vcs.init(geometry=(600, 400))
canvas.open()
canvas.png("test", width=800, height=500)
Important Note:
vcs
will attempt to keep image dimensions as portrait or landscape, depending on the current size of your canvas. This means that if you callcanvas.png("file", width=600, height=300)
but your canvas’ dimensions are500
x800
, your output will be300
x600
.
You can now specify the appearance of continents using the vcs line
primitive and the continents_line
keyword of the canvas.plot
function. A simple example can be found here