Style
In [1]:
Copied!
from chalk.core import BaseDiagram
from chalk import *
def help(f):
import pydoc
from IPython.display import HTML
return HTML(pydoc.HTMLDoc().docroutine(f))
from chalk.core import BaseDiagram from chalk import * def help(f): import pydoc from IPython.display import HTML return HTML(pydoc.HTMLDoc().docroutine(f))
Diagrams can be styled using standard vector graphic style primitives. Colors use the Python colour library.
In [2]:
Copied!
from colour import Color
blue = Color("blue")
orange = Color("orange")
from colour import Color blue = Color("blue") orange = Color("orange")
Diagram.fill_color¶
In [3]:
Copied!
help(BaseDiagram.fill_color)
help(BaseDiagram.fill_color)
Out[3]:
- fill_color(self: 'TStyle', color: 'Color') -> 'TStyle'
In [4]:
Copied!
triangle(1).fill_color(blue)
triangle(1).fill_color(blue)
Out[4]:
Diagram.fill_opacity¶
In [5]:
Copied!
help(BaseDiagram.fill_opacity)
help(BaseDiagram.fill_opacity)
Out[5]:
- fill_opacity(self: 'TStyle', opacity: 'float') -> 'TStyle'
In [6]:
Copied!
triangle(1).fill_color(blue).fill_opacity(0.2)
triangle(1).fill_color(blue).fill_opacity(0.2)
Out[6]:
Diagram.line_color¶
In [7]:
Copied!
help(BaseDiagram.line_color)
help(BaseDiagram.line_color)
Out[7]:
- line_color(self: 'TStyle', color: 'Color') -> 'TStyle'
In [8]:
Copied!
triangle(1).line_color(blue)
triangle(1).line_color(blue)
Out[8]:
Diagram.line_width¶
In [9]:
Copied!
help(BaseDiagram.line_width)
help(BaseDiagram.line_width)
Out[9]:
- line_width(self: 'TStyle', width: 'float') -> 'TStyle'
In [10]:
Copied!
triangle(1).line_width(0.05)
triangle(1).line_width(0.05)
Out[10]:
Diagram.dashing¶
In [11]:
Copied!
help(BaseDiagram.dashing)
help(BaseDiagram.dashing)
Out[11]:
- dashing(self: 'TStyle', dashing_strokes: 'List[float]', offset: 'float') -> 'TStyle'
In [12]:
Copied!
triangle(1).dashing([0.2, 0.1], 0)
triangle(1).dashing([0.2, 0.1], 0)
Out[12]:
Advanced Example¶
Example: Outer styles override inner styles
In [13]:
Copied!
(triangle(1).fill_color(orange) | square(2)).fill_color(blue)
(triangle(1).fill_color(orange) | square(2)).fill_color(blue)
Out[13]:
Last update: 2022-08-19