0

I'm trying to make an application in WPF and I want to include a polar heat map such as can be done using matplotlib in Python fairly easily. I.E.

import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
plt.subplot(projection='polar')

r = np.linspace(0,1,100) # radius
t = np.linspace(0,2*np.pi, 100) # angle

R, T = np.meshgrid(r,t)
Z = R*R

plt.pcolormesh(T,R,Z)
plt.grid()
plt.thetagrids([theta*45 for theta in range(360//45)])
plt.show()

I'm trying to achieve this using OxyPlot 2.0.0 in C# & XAML, however there is no native support for this as far as I'm aware of. I have tried searching for a solution, and came across this issue in the github repository: https://github.com/oxyplot/oxyplot/issues/911, where PolarColorHeatMapSeries is being mentioned, which would be exactly what I need. However, I'm unable to find how I should implement this. Thus I think I have several options:

  1. Use the regular heatmap, transform (x,y) to (r,theta) and set pixels out of a certain radius to double.NaN. Thereafter, overlay it with an empty polar plot to show polar axes. I have stacked two separate PlotViews. This doesn't feel (and look) right.
  2. Use a canvas and construct this myself. Plot every pixel as a rectangle. However, I'm not sure how I should create the polar axes in this case.

Can anyone give me pointers on where to start this?

Kind regards.

Tom
  • 37
  • 1
  • 6
  • I did some poking around and didn't find much either. However, here is an implementation that might help get you there... https://github.com/dsuarezv/arduino.net/blob/master/libs/oxyplot/src/Source/Examples/ExampleLibrary/CustomSeries/PolarHeatMapSeries.cs – Gordon Slysz Dec 11 '19 at 19:29
  • Thank you Gordon, this file really helped a lot. I made some minor adjustments to this file (which I also found thereafter, buried in the examples section of the github repository) and got it to work! So the answer to my question is quite simple: have a look at the official oxyplot github repository! – Tom Dec 16 '19 at 14:23
  • Glad that link helped! I'll post it as an answer. Note that the link points to a fork of the official repository – Gordon Slysz Dec 16 '19 at 18:52

0 Answers0