-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Dear developers,
thanks a lot for providing this library! By testing around I encountered a bug in the support of providing own axes.
When having a subplots with more than one axes, the output is not as intended despite providing the correct axis. In particular the output is

while the upper figure should look like
.
The code leading to both figures is attached below.
I suggest the adaption of the implementations referenced in draw_interaction() as well as draw_interaction() itself as they use plt.plot(...) instead of ax.plot(...).
I thank you for fixing this issue.
Kind regards,
Erik
import parasbolv as psv
import matplotlib.pyplot as plt
from collections import namedtuple
Part = namedtuple('part', ['glyph_type', 'orientation', 'user_parameters', 'style_parameters'])
Interaction = namedtuple('interaction', ['starting_glyph', 'ending_glyph', 'interaction_type', 'interaction_parameters'])
part_list = []
part_list.append(Part('CDS',
'forward',
None,
{'cds': {'facecolor': (1, 0.5, 0.5), 'edgecolor': (1,0,0), 'linewidth': 2}}
) )
part_list.append(Part('Terminator', 'forward', None, None))
part_list.append(Part("Promoter", "forward", None, None))
part_list.append(Part('CDS',
'forward',
None,
{'cds': {'facecolor': (1, 0.5, 0.5), 'edgecolor': (1,0,0), 'linewidth': 2}}
) )
part_list.append(Part('Terminator', 'forward', None, None))
part_list.append(Part("Promoter", "forward", None, None))
# Create renderer
renderer = psv.GlyphRenderer()
# Create list of interactions to pass to render_part_list
interaction_list = []
interaction_list.append(Interaction(part_list[0], part_list[2], 'inhibition', {'color': (0.75,0,0)}))
# interaction_list.append(Interaction(part_list[0], part_list[1], 'inhibition', {'color': (0.75,0,0)}))
# interaction_list.append(Interaction(part_list[2], part_list[4], 'control', {'color': (0, 0.75, 0),
# 'direction':'reverse'}))
# Plot Construct
error_case = True
if error_case:
fig, axes = plt.subplots(ncols=1, nrows=2)
ax = axes[0]
figure_name = "errornous_visualization.png"
else:
fig, axes = plt.subplots(ncols=1, nrows=1)
ax = axes
figure_name = "intended_visualization.png"
construct = psv.Construct(part_list, renderer, interaction_list=interaction_list, fig=fig, ax=ax, start_position=(0, 0))
fig, ax, baseline_start, baseline_end, bounds = construct.draw()
ax.plot([baseline_start[0], baseline_end[0]], [baseline_start[1], baseline_end[1]], color=(0,0,0), linewidth=1.5, zorder=0)
# You can also manually plot interactions:
interaction_bounds = psv.draw_interaction(ax, ((120, 15), (50, 0)), ((60, 0), (60, 0)), 'process', None)
plt.savefig(figure_name)
plt.show()
Metadata
Metadata
Assignees
Labels
No labels