Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve plot data handling #54

Merged
merged 77 commits into from
Aug 20, 2021
Merged

Improve plot data handling #54

merged 77 commits into from
Aug 20, 2021

Conversation

janssenhenning
Copy link
Contributor

@janssenhenning janssenhenning commented Jun 6, 2021

Also see #26

This PR implements a way to provide data to the plotting functions in many different ways while keeping the plotting functions consistent and simple.

A class PlotData is added, which acts as a light wrapper around mappings of many kinds (dicts, dataframe, ColumnDataSources), which can be used to easily handle multiple datasets. Suppose we have a dict data with a key x and y1 and y2 and we want to plot the y keys both against x

from masci_tools.vis.data import PlotData

p = PlotData(data, x='x', y=['y1','y2'])

for entry, source in p.items():
    print('x', entry.x, source[entry.x]) 
    print('y', entry.y, source[entry.y])

The above example will yield two items with x vs y1 and x vs. y2, source is the dict data in both cases. Notice that the chosen names x and y are completely arbitrary. With the initialization we define how our data columns should be named.

PlotData also has some convenience methods for mutating/copying/getting information about the data

In addition a function process_data_arguments is implemented, which can either take a mapping and kwargs to directly Initialize the PlotData as above. But it is also possible to provide only the kwargs with the wanted data in arrays/lists/series, which are then split up and put into dicts to initialize a PlotData object

@janssenhenning janssenhenning added enhancement New feature or request visualization Related to the visualization routines labels Jun 6, 2021
@codecov
Copy link

codecov bot commented Jun 7, 2021

Codecov Report

Merging #54 (a5ed43d) into develop (e4d9ea2) will increase coverage by 3.03%.
The diff coverage is 88.87%.

❗ Current head a5ed43d differs from pull request most recent head d722bc9. Consider uploading reports for the commit d722bc9 to get more accurate results
Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #54      +/-   ##
===========================================
+ Coverage    78.15%   81.18%   +3.03%     
===========================================
  Files          100      102       +2     
  Lines        18568    20414    +1846     
===========================================
+ Hits         14512    16574    +2062     
+ Misses        4056     3840     -216     
Impacted Files Coverage Δ
masci_tools/vis/bokeh_plotter.py 70.30% <56.33%> (+38.40%) ⬆️
masci_tools/vis/bokeh_plots.py 49.54% <68.42%> (+41.66%) ⬆️
masci_tools/vis/matplotlib_plotter.py 85.77% <68.42%> (-1.62%) ⬇️
masci_tools/vis/fleur.py 81.38% <87.17%> (+7.64%) ⬆️
masci_tools/vis/data.py 87.73% <87.73%> (ø)
masci_tools/vis/plot_methods.py 62.81% <88.41%> (+2.07%) ⬆️
masci_tools/vis/parameters.py 91.56% <91.66%> (+0.68%) ⬆️
tests/conftest.py 95.61% <94.00%> (-0.34%) ⬇️
tests/test_plot_data.py 99.41% <99.41%> (ø)
masci_tools/io/common_functions.py 93.47% <100.00%> (-1.45%) ⬇️
... and 30 more

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 e4d9ea2...d722bc9. Read the comment docs.

@janssenhenning
Copy link
Contributor Author

janssenhenning commented Jul 22, 2021

TODO:

  • Investigate how PlotData behaves for nan values (probably some extra care has to be taken)
  • Implement Unit tests for PlotData
  • bokeh dependency is not optional at the moment (import in data.py)

@janssenhenning janssenhenning force-pushed the plot-data branch 2 times, most recently from 03d45f5 to 47b82a2 Compare August 9, 2021 10:57
@janssenhenning janssenhenning mentioned this pull request Aug 10, 2021
@janssenhenning janssenhenning force-pushed the plot-data branch 2 times, most recently from e117e85 to fd7008b Compare August 15, 2021 12:25
…ial cases in the PlotData class

Removed mask and __getitem__ from PlotData as they are not used and are also not really implemented completely. If they are needed they need to be redone anyway
concat does not overwrite an already existing column
A shallow copy will not copy the data attribute
Manual configuration with output_file/output_notebook is needed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request visualization Related to the visualization routines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant