In [1]:
import autofig
import numpy as np
import astropy.units as u
autofig works by creating a hierarchy of objects which dictates how a figure should be rendered. These exist at three main levels:
Calling autofig.plot is simply a shortcut to accessing a built-in Figure object. We can access this object via autofig.gcf() (get current figure) at anytime, or can call the plot method of an instantiated Figure directly.
In [2]:
autofig.reset()
autofig.plot(x=[1,2,3], xunit='s', y=[1,2,3], c=[1,2,3], i='x', uncover=True)
autofig.gcf()
Out[2]:
In [3]:
figure = autofig.Figure()
figure.plot(x=[1,2,3], xunit='s', y=[1,2,3], c=[1,2,3], i='x', uncover=True)
figure
Out[3]:
The Figure object holds the collection of Axes objects and is in charge of the subplot layout. As such, it does not currently accept or hold many options.
The Figure object has the following methods:
From the Figure object, you can access the list of children axes:
In [4]:
figure.axes
Out[4]:
as well as the list of all Call objects in those axes:
In [5]:
figure.calls
Out[5]:
In [6]:
axes = figure.axes[0]
axes
Out[6]:
In [7]:
axes.equal_aspect
Out[7]:
In [8]:
axes.pad_aspect
Out[8]:
The Axes object has the following methods:
From the Axes object, you can access the parent Figure or a list of the children Call objects
In [9]:
axes.figure
Out[9]:
In [10]:
axes.calls
Out[10]:
As well as any of its dimensions (i, x, y, z)
In [11]:
axes.x
Out[11]:
Or a combination of the cartesian dimensions
In [12]:
axes.xyz
Out[12]:
In [13]:
axes.xy
Out[13]:
or a list of its color/size dimensions (cs, ss)
In [14]:
axes.cs
Out[14]:
In [15]:
ad = axes.x
ad
Out[15]:
In [16]:
ad.unit
Out[16]:
In [17]:
ad.unit='d'
ad.unit
Out[17]:
In [18]:
ad.pad
Out[18]:
In [19]:
axes.pad=0.05
ad.pad
Out[19]:
In [20]:
ad.pad=0.15
axes.pad=0.08
ad.pad
Out[20]:
In [21]:
ad.lim
Out[21]:
In [22]:
ad.pad=0.0
ad.lim
Out[22]:
In [23]:
ad.label
Out[23]:
In [24]:
ad.label='mylabel'
ad.label_with_units
Out[24]:
In [25]:
ad.axes
Out[25]:
In [26]:
lsc = axes.linestylecycler
lsc
Out[26]:
The cycle defines the order at which the properties will be drawn.
In [27]:
lsc.cycle
Out[27]:
If desired, you can change this default order (Note: the cycle can be shorter than the original, but you cannot add new items)
In [28]:
lsc.cycle = ['dashed', 'dotted', 'dashdot', 'solid']
In [29]:
plot = axes.calls[0]
plot
Out[29]:
In [30]:
plot.kwargs
Out[30]:
In [31]:
plot.highlight
Out[31]:
In [32]:
plot.highlight_marker
Out[32]:
If None, highlight_size will default to size
In [33]:
plot.highlight_size
Out[33]:
In [34]:
plot.highlight_linestyle
Out[34]:
If None, highlight_color will default to color
In [35]:
plot.highlight_color
In [36]:
plot.uncover
Out[36]:
In [37]:
plot.uncover=True
ad.get_lim(i=1.5)
Out[37]:
In [38]:
plot.uncover=False
ad.get_lim(i=1.5)
Out[38]:
In [39]:
plot.consider_for_limits=False
ad.get_lim(i=1.5)
Out[39]:
In [40]:
plot.consider_for_limits=True
ad.get_lim(i=1.5)
Out[40]:
The Plot object has a link back to its parent Axes and grandparent Figure objects.
In [41]:
plot.axes
Out[41]:
In [42]:
plot.figure
Out[42]:
In [43]:
pd = plot.x
pd
Out[43]:
In [44]:
pd.unit
Out[44]:
In [45]:
pd.label
In [46]:
pd.get_value()
Out[46]:
In [47]:
plot.uncover=False
pd.get_value(i=1.5)
Out[47]:
In [48]:
plot.uncover=True
pd.get_value(i=1.5)
Out[48]:
In [49]:
pd.interpolate_at_i(i=1.5)
Out[49]:
The CallDimension objects have shortcuts back to their parent Call (Plot or Mesh)
In [50]:
pd.call
Out[50]: