glue-viz / glue-plotly

Experimental plot.ly plugin for glue
BSD 3-Clause "New" or "Revised" License
2 stars 8 forks source link

Add support for 2D polar scatterplots. #12

Closed Carifio24 closed 2 years ago

Carifio24 commented 2 years ago

This PR adds support for exporting polar scatterplots. This is accomplished by using the plotly.graph_objs.layout.Polar layout.

The tick marks for the radial axis are grabbed directly from the scatter viewer and italicized via HTML tags (as best as I can see, there's no option to directly italicize the font). For the theta axis, the formatting used to create the pi symbol in the ticks in matplotlib doesn't work in plotly, so rather than try some sort of text replacement hack, this PR just lets plotly use its own tick marks and adds a suffix for the theta=0 marker.

Some examples of the output are here. Most of these are using the W5 dataset, but the output of the polar plot used in the airplane video is in there as well (that file takes a few seconds to load).

codecov[bot] commented 2 years ago

Codecov Report

Merging #12 (57fdb81) into main (273866f) will increase coverage by 1.06%. The diff coverage is 97.56%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #12      +/-   ##
==========================================
+ Coverage   85.04%   86.11%   +1.06%     
==========================================
  Files           8        8              
  Lines         361      396      +35     
==========================================
+ Hits          307      341      +34     
- Misses         54       55       +1     
Impacted Files Coverage Δ
glue_plotly/html_exporters/scatter2d.py 82.17% <95.65%> (+3.42%) :arrow_up:
glue_plotly/html_exporters/tests/test_scatter2d.py 98.00% <100.00%> (+0.77%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 273866f...57fdb81. Read the comment docs.

Carifio24 commented 2 years ago

I've added a changelog entry, as well as tests using both radians and degrees that follow the same pattern as the rectilinear test. I refactored the export of the figure into its own function since it would've been essentially identical in all three tests.

I should note that the polar plots in the test output don't have radial axis labels. This is because the exporter directly uses the axis labels for the radial axis, which seem to all be empty when running glue via a call toGlueApplication() like we do in the test.