I am very new to P5 and want to code a circular heatmap inP5 based on data I have
Something similar like shown in the figure.
I already manage to do it in R, but really need to do it in p5 and already unsucessfully searched the internet for hours and days to find sample code of how to code a circular heatmap in P5.js.
Is there a specific reason you want to do this in p5.js and not d3? Just asking, because d3 has a lot of fully developed modules just for things like data driven circular heat maps.
The easiest way to draw a collection of radial segments like this is:
loop over the table like a checkerboard β starting from the outer row and moving inward, so that each row of the data is a ring on your chart, with one tile per column. Outer first β this maters for rendering. If your data is organized inner-first then loop over it backwards.
Draw each tile using arc: https://p5js.org/reference/#/p5/arc. Your arc width is TWO_PI / columnCount. These tiles are actually pie slices, but the inner rings will crop them to tiles.
What I want is something as displayed on the sketch in my last post (see above). In that sketch, the transparant layer is sketched with PowerPoint and looks not smooth , so therefero I hope this would be possible in P5 to add a kind of transparant layer connecting the blue dots and a second transparant layer in green connecting the green dots on the sketch provided in my last response.
Well, because you are using rotate and essentially drawing with polar coordinates, this is a bit harder than it needs to be, but not too bad.
refactor draw_circplot() so that you call it twice β once for each data series
use beginShape / vertex / endShape to draw your shaded outlines
in order to do this, you must convert your polar coordinates into cartesian. Thatβs pretty easy; the formulas are x = r * cos(theta) β¦ y = r * sin(theta).