Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/cowpatch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from .layout_elements import layout, area
from .base_elements import patch
#from .text_elements import text
from .text_elements import text
from .annotation_elements import annotation
#from .wrappers import wrapper_plotnine, wrapper_matplotlib, wrapper_seaborn
from .config import rcParams
1,156 changes: 1,156 additions & 0 deletions src/cowpatch/annotation_elements.py

Large diffs are not rendered by default.

1,289 changes: 1,008 additions & 281 deletions src/cowpatch/base_elements.py

Large diffs are not rendered by default.

23 changes: 22 additions & 1 deletion src/cowpatch/config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import plotnine as p9

rcParams = dict(maxIter=20,
min_size_px=10,
eps=1e-2,
Expand All @@ -8,7 +10,26 @@
num_attempts=2,

base_height=3.71,
base_aspect_ratio=1.618 # the golden ratio
base_aspect_ratio=1.618, # the golden ratio

cow_text=p9.element_text(
family=p9.options.get_option("base_family"),
style='normal',
color='black',
size=1.2*11,
linespacing=0.9,
ha='center',
va='center',
rotation=0,
margin={}),
cow_tag=p9.element_text(size=1.2*11,
ha="left"),
cow_title=p9.element_text(size=1.2*11,
ha="left"),
cow_subtitle=p9.element_text(size=11,
ha="left"),
cow_caption=p9.element_text(size=.8*11,
ha="right"),

)
"""
Expand Down
14 changes: 11 additions & 3 deletions src/cowpatch/layout_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ def _yokogaki_ordering(self, num_grobs=None):
"with self.num_grobs")
num_grobs = self.num_grobs

areas = self._element_locations(1,1) # basically getting relative positions (doesn't matter) - nor does it matter about rel_height and width, but ah well
areas = self._element_locations(1,1, num_grobs=num_grobs) # basically getting relative positions (doesn't matter) - nor does it matter about rel_height and width, but ah well
all_x_left = np.array([a.x_left for a in areas])
all_y_top = np.array([a.y_top for a in areas])

Expand Down Expand Up @@ -624,8 +624,16 @@ def __eq__(self, value):
return design_logic and \
self.ncol == value.ncol and \
self.nrow == value.nrow and \
np.unique(self.rel_heights/value.rel_heights).shape[0] == 1 and \
np.unique(self.rel_widths/value.rel_widths).shape[0] == 1
(
((self.rel_heights is None) and (value.rel_heights is None))
or
(np.unique(self.rel_heights/value.rel_heights).shape[0] == 1)
) and \
(
((self.rel_widths is None) and (value.rel_widths is None))
or
(np.unique(self.rel_widths/value.rel_widths).shape[0] == 1)
)


class area:
Expand Down
22 changes: 21 additions & 1 deletion src/cowpatch/svg_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,27 @@ def _show_image(svg, width, height, dpi=300, verbose=True):



def _add_to_base_image(base_image, current_image, loc = (0,0)):
"""
append current image into base_image at location loc

Arguments
---------
base_image : svg object
base image object
current_image : svg object
new image object to be added to the base image
loc : tuple
top left corner location for the new image to be placed (within the
base_image)
"""
inner_root = current_image.getroot()
inner_root.moveto(x=loc[0],
y=loc[1])
base_image.append(inner_root)

return None

def _uniquify_svg_safe(svg_obj, str_update):
"""
Update svg code to 'uniquify' svg but by making sure 'url(#___)'
Expand Down Expand Up @@ -544,4 +565,3 @@ def _uniquify_svg_str_safe(svg_str, str_update):

return svg_str


Loading