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

Implement new chart type - Polar Plot #39

Open
KarthikRIyer opened this issue Nov 25, 2019 · 19 comments
Open

Implement new chart type - Polar Plot #39

KarthikRIyer opened this issue Nov 25, 2019 · 19 comments

Comments

@KarthikRIyer
Copy link
Owner

KarthikRIyer commented Nov 25, 2019

The current LineChart implementation uses rectangular coordinates. It would be good to have a plot type that helps us plot data using polar coordinates.
Details about what a polar plot is can be found here.
A simple example of a polar plot can be found here.

This task will require you to implement the following:

  • A new plot type (PolarPlot) similar to LineChart, BarChart implemented currently. (Very basic implementation. You need not implement support for multiple series, although that would be a great addition.)
  • Add functions to atleast two from the three renderers (AGG/SVG/CoreGraphics) to draw an empty circle.

The input type can be Pair<FloatConvertible , FloatConvertible>. The end user should be able to create plots using an array of (r,θ) values or a function that returns r at a specific θ [ r = f(θ) ].

@areebg9
Copy link
Contributor

areebg9 commented Jan 13, 2020

Hi! I'm not sure whether I'll take this task or not, but is it okay if I look at it in the meantime?

Thanks!

@KarthikRIyer
Copy link
Owner Author

Sure @Qwerty71 ! Let me know if you need any help getting started.

@areebg9
Copy link
Contributor

areebg9 commented Jan 17, 2020

Hey! I was wondering how to resize a plot so that it's in a 1:1 ratio (for example, ax.set_aspect() in matplotlib in python). I've got the polar coordinates working, I just need to get it into an organized package file.

In addition, am I allowed to use LineChart within my implementation? Or would you like me to create it from scratch?

@KarthikRIyer
Copy link
Owner Author

At the moment there's no way to set the aspect ratio. But while creating the plot the end user may set the width and height of the plot in the initializer.

I'd be interested to see how you've used LineChart to get polar plots working. Also, could you share preliminary plots that you have been able to make?

@areebg9
Copy link
Contributor

areebg9 commented Jan 18, 2020 via email

@areebg9
Copy link
Contributor

areebg9 commented Jan 18, 2020

Screen Shot 2020-01-18 at 9 40 56 AM

Here's a basic polar plot that I made. I had to hard-code the circles, but when I implement them, I'll automate them to behave such as grid lines. Inside, there is a limacon with 4 "petals," and a spiral.

As you can see, the image appears to be stretched - yes, those should be circles, not ovals - so that's why I was asking about the aspect ratio.

@areebg9
Copy link
Contributor

areebg9 commented Jan 18, 2020

If you look at the legend, you'll see that it contains a graph for how addFunction would work (e.g. r = 2costheta) and addSeries (hardcoded values for r and theta).

@areebg9
Copy link
Contributor

areebg9 commented Jan 18, 2020

I've selected this task on the GCI homepage - I linked to my notebook there.

@KarthikRIyer
Copy link
Owner Author

There's no way to set the aspect ratio explicitly. You'll have to set the width and height. Also I'd prefer if you didn't reuse LineChart to implement polar plots because in a polar plot we don't want the coordinates to be (x,y), but (r,θ) just like in matplotlib. We want results as close as possible to matplotlib so that people can transition from matplotlib to swiftplot easily.

@areebg9
Copy link
Contributor

areebg9 commented Jan 19, 2020 via email

@areebg9
Copy link
Contributor

areebg9 commented Jan 19, 2020

Just an update - I've solved my previous problem (converting Float to FloatConvertible), and I've got the code working (I just modified the code for LineChart.swift, I will mention that on the top of the code). All I need to do now is add the circle "gridlines," and I'll also see if I can fix the aspect ratio as well.

The notebook demonstrating how it works (now updating, actually getting code from my forked repo) is on the GCI comments.

@areebg9
Copy link
Contributor

areebg9 commented Jan 19, 2020

Would you like me to provide compatibility with all of the addSeries functions (you can either input a list of Points, x and y, or just y)?

@KarthikRIyer
Copy link
Owner Author

Input can be an array of (r,theta) or single r,theta pairs.

@KarthikRIyer
Copy link
Owner Author

Instead of trying to fix the aspect ratio, just use one parameter like imageSize, which will be both the width and height of the image.

@areebg9
Copy link
Contributor

areebg9 commented Jan 23, 2020

Hey, I'm getting this error after trying to install SwiftPlot after making my changes:

undefined symbol: _ZN14CPPAGGRenderer17draw_empty_circleEfffPKv

I created a new function, draw_empty_circle as per the task request. I checked in all the .cpp and .h files for AGGRenderer, CAGGRenderer, and CPPAGGRenderer, and it's defined in all of those.

The inputs of (r, theta) are working for both addSeries() and addFunction(). All I need is to implement this and I'll be set.

@KarthikRIyer
Copy link
Owner Author

Could you open a PR with your updated code. I'll take a look.

@areebg9
Copy link
Contributor

areebg9 commented Jan 23, 2020

With the current code (that produces the error)? Or everything without that portion?

@KarthikRIyer
Copy link
Owner Author

The complete code with the error.

@areebg9
Copy link
Contributor

areebg9 commented Jan 23, 2020

Ok.

@KarthikRIyer KarthikRIyer removed the GCI label Apr 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants