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

First attempt at histogram3d/legoplot #3507

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

briederer
Copy link
Contributor

As already mentioned in #3379 I wanted to add a histogram3d() function for plotting.
Therefore I took over the ides from the issue and translated it in a recipe, however now I am a bit stuck.

The main problems + possible solutions are:

  1. wireframe is not reliable across the different backends (very different behaviours) so I switched to surface
  2. surface does not provide a mesh option (like surface + wireframe) and so one does not get a lot of information from the plots.
    • solution 1: adding all the lines manually? may be very resource intensive
    • solution 2: Adding a wireframe? does not provide the correct overlay properties depending on the backend
  3. color: Should it be one color like it is done for usual histograms or would it be nicer to have colored bars depending on their height (like a heatmap not seen from above)?
  4. Additionally I wanted to add the same possibility as in 2d-histograms to use the attribute show_empty_bins which turned out to be really hard. Especially the plotly() backend seems to have a lot of trouble with a mixture of NaN and numeric-values at the same x-y position.
    • Additionally this needs the _allneighbours function which checks if all neighbours in a matrix are the same value, which I need to set the NaN-values for the plot. I really dislike this function a lot but I couldn't wrap my head around another idea to resolve this

Figures

All plots are created by

x=rand(100)
y=rand(100)
histogram3d(x,y,bins=(10,10),camera=(20,60),xlabel="x")

GR

One-coloured surface plot

  • Good: Shows bins as expected
  • Bad: Not very useful without lines at the edges (Problem 2 from above)
    hist3d_blue_gr

Multi-coloured surface plot

  • Good: Shows bins as expected, able to separate different bins by color
  • Bad: Color gradient messes here with the plot, would be better to have one fixed color for each bar instead of a gradient (How to resolve this?)
    hist3d_colored_gr

Single-coloured surface + wireframe plot

Not possible with the current solution, wince wireframe in GR needs x and y values in ascending (i.e. repeated values are forbidden). Therefore one would need again the workaround with repeateps() in #3379 which I have discarded for now.

Plotly

One-coloured surface plot

  • Good: Bins separable by eye due to automatic shadows in plotly
  • Bad: lines at the edges would still be helpful (Problem 2 from above), NaN-values are not completely correct rendered as can be seen at for instance x=0.2 and y = 0.0 to 0.1 by a missing part of the wall.
    hist3d_blue_plotly

Multi-coloured surface plot

  • Good: Shows bins as expected, able to separate different bins by color
  • Bad: Color gradient messes here with the plot, would be better to have one fixed color for each bar instead of a gradient (How to resolve this?), also here problem with NaN-values e.g. at x=0.4
    hist3d_colored_plotly_2
    hist3d_colored_plotly

Single-coloured surface + wireframe plot

  • Good: Bins separable by eye due to automatic shadows in plotly
  • Bad: Wireframe lines are definitely not displayed as expected
    hist3d_colored_wf_plotly

Pyplot

Already worked yesterday, but somehow is not compiling at the moment on my PC. I'll try to add figures as soon as possible.

Further info

I am totally willing to expand this myself but I also definitely need some help (and also style-decisions) here. So let me know if you have any idea. Also @dorn-gerhard it would be really nice if your colleagues could add their solutions as proposed in #3379

Thanks already and Cheers.

@briederer
Copy link
Contributor Author

briederer commented May 17, 2021

And please could someone add the help wanted label since I don't have permissions to add labels 😅

@codecov
Copy link

codecov bot commented May 17, 2021

Codecov Report

Merging #3507 (a74007e) into master (97036e6) will decrease coverage by 0.30%.
The diff coverage is 0.00%.

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

@@            Coverage Diff             @@
##           master    #3507      +/-   ##
==========================================
- Coverage   64.05%   63.75%   -0.31%     
==========================================
  Files          27       27              
  Lines        6611     6643      +32     
==========================================
  Hits         4235     4235              
- Misses       2376     2408      +32     
Impacted Files Coverage Δ
src/recipes.jl 54.53% <0.00%> (-1.98%) ⬇️
src/shorthands.jl 45.83% <ø> (ø)

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 a7d6e93...1482874. Read the comment docs.

@briederer
Copy link
Contributor Author

Added now another possibility to tackle this problem, by really plotting 3d-bars at each x-y-spot as a separate series.
This works more reliable across backends but becomes very unfeasible for too much bins i.e. bins=(10,10) already creates 100 bars which uses a lot of memory.

Also in gr() the order of the series matters because otherwise a bar in the background overlay one in the front.

I will try to resolve this by not plotting one bar at each x-y-spot but instead plot one surface for each connected area (e.g. one slice from x[i] to x[i+1] for all y-values, or really trying to identify isolated areas). This should reduce the amount of unnecessary planes by a huge amount.

@briederer
Copy link
Contributor Author

I will try to resolve this by not plotting one bar at each x-y-spot but instead plot one surface for each connected area (e.g. one slice from x[i] to x[i+1] for all y-values, or really trying to identify isolated areas). This should reduce the amount of unnecessary planes by a huge amount.

However this will make it harder again to have differently colored bars.

@BeastyBlacksmith BeastyBlacksmith marked this pull request as draft July 5, 2021 15:46
@t-bltg t-bltg added the WIP Work in progress, do not merge! label Jul 6, 2021
@briederer briederer mentioned this pull request Jul 6, 2021
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted WIP Work in progress, do not merge!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants