Skip to content

Commit

Permalink
Clean up Matplotlib code: remove altair code and replace pandas code (#…
Browse files Browse the repository at this point in the history
…326)

* rec series

* rec

* add changes back

* fix tests

* rm

* change

* set plotting_style

* nice

* black

* rm

* change rec

* reuse export

* remove altair

* nice

* rm

* fix

* fix merge

* rm

* black

Co-authored-by: Caitlyn Chen <caitlynachen@berkeley.edu>
  • Loading branch information
caitlynachen and Caitlyn Chen committed Mar 30, 2021
1 parent b8b64bf commit 2525d71
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 16 deletions.
13 changes: 1 addition & 12 deletions lux/vislib/matplotlib/BarChart.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def initialize_chart(self):
bar_attr = x_attr.attribute

k = 10
self._topkcode = ""
n_bars = len(self.data.iloc[:, 0].unique())
if n_bars > k: # Truncating to only top k
remaining_bars = n_bars - k
Expand All @@ -79,17 +78,7 @@ def initialize_chart(self):
color="#ff8e04",
)

self._topkcode = f"""text = alt.Chart(visData).mark_text(
x=155,
y=142,
align="right",
color = "#ff8e04",
fontSize = 11,
text=f"+ {remaining_bars} more ..."
)
chart = chart + text\n"""

df = pd.DataFrame(self.data)
df = self.data

bars = df[bar_attr].apply(lambda x: str(x))
measurements = df[measure_attr]
Expand Down
2 changes: 1 addition & 1 deletion lux/vislib/matplotlib/Heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def initialize_chart(self):
if len(y_attr.attribute) > 25:
y_attr_abv = y_attr.attribute[:15] + "..." + y_attr.attribute[-10:]

df = pd.DataFrame(self.data)
df = self.data

plot_code = ""
color_attr = self.vis.get_attr_by_channel("color")
Expand Down
2 changes: 1 addition & 1 deletion lux/vislib/matplotlib/Histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def initialize_chart(self):

markbar = abs(x_max - x_min) / 12

df = pd.DataFrame(self.data)
df = self.data

bars = df[msr_attr.attribute]
measurements = df["Number of Records"]
Expand Down
2 changes: 1 addition & 1 deletion lux/vislib/matplotlib/LineChart.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def initialize_chart(self):

self.data = self.data.dropna(subset=[x_attr.attribute, y_attr.attribute])

df = pd.DataFrame(self.data)
df = self.data

x_pts = df[x_attr.attribute]
y_pts = df[y_attr.attribute]
Expand Down
2 changes: 1 addition & 1 deletion lux/vislib/matplotlib/ScatterChart.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def initialize_chart(self):
if len(y_attr.attribute) > 25:
y_attr_abv = y_attr.attribute[:15] + "..." + y_attr.attribute[-10:]

df = pd.DataFrame(self.data)
df = self.data

x_pts = df[x_attr.attribute]
y_pts = df[y_attr.attribute]
Expand Down

0 comments on commit 2525d71

Please sign in to comment.