Skip to content

Commit

Permalink
reverting to returning fig rather than ax to be consistent with the r…
Browse files Browse the repository at this point in the history
…est of the repo
  • Loading branch information
kbonney committed Nov 3, 2023
1 parent 6e61083 commit cbaebb6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions pvops/tests/test_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def test_visualize_attribute_connectivity():

om_col_dict = {"attribute1_col": "Attr1", "attribute2_col": "Attr2"}

ax, G = visualize.visualize_attribute_connectivity(
fig, G = visualize.visualize_attribute_connectivity(
df,
om_col_dict,
figsize=(10, 8),
Expand All @@ -289,7 +289,7 @@ def test_visualize_attribute_connectivity():
},
)

assert isinstance(ax, matplotlib.axes.Axes)
assert isinstance(fig, matplotlib.pyplot.Figure)
assert list(G.edges()) == [("A", "X"), ("B", "X"), ("C", "Y"), ("C", "Z")]

matplotlib.pyplot.close()
Expand Down
11 changes: 4 additions & 7 deletions pvops/text/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def visualize_attribute_connectivity(
attribute_colors=["lightgreen", "cornflowerblue"],
edge_width_scalar=10,
graph_aargs={},
ax=None,
):
"""Visualize a knowledge graph which shows the frequency of combinations between attributes
``ATTRIBUTE1_COL`` and ``ATTRIBUTE2_COL``
Expand Down Expand Up @@ -64,17 +63,15 @@ def visualize_attribute_connectivity(
- font_weight='bold'
- node_size=19000
- font_size=35
ax : axis
axis to draw on, defaults to None and will create a new figure and axis in this case.
Returns
-------
Matplotlib axis,
networkx graph
"""
if ax is None: # create a new figure
fig = plt.figure(facecolor='w', edgecolor='k')
ax = plt.gca()
# initialize figure
fig = plt.figure(figsize=figsize,facecolor='w', edgecolor='k')
ax = plt.gca()

# attribute column names
ATTRIBUTE1_COL = om_col_dict["attribute1_col"]
Expand Down Expand Up @@ -136,7 +133,7 @@ def visualize_attribute_connectivity(

plt.show(block=False)

return ax, G
return fig, G


def visualize_attribute_timeseries(
Expand Down

0 comments on commit cbaebb6

Please sign in to comment.