KarthikRIyer / swiftplot

Swift library for Data Visualization :bar_chart:
Apache License 2.0
401 stars 39 forks source link

Add secondary axis feature #16

Closed KarthikRIyer closed 5 years ago

KarthikRIyer commented 5 years ago

12

I've added a secondary axis. The user can specify the axis while adding the series like so:

lineGraph.addSeries(x, y, label: "Plot 2", color: Color.orange, axisType: Axis.SECONDARY_AXIS)

By default the axis is the primary one. To differentiate between the series for both axes, I've made the series for secondary axis dashed.

I've also added an overload for the addSeries function with just the y-values passed in. In this case the x-values will be [1, 2, 3, 4, ...]

Once this is merged, I think the main stuff for the 1st milestone will have been covered as discussed in the email:

To summarise what I can do for milestone 1:

  • Make a simple Line Chart imaplementation with SubPlot support.
  • Setup tests that saves images next to the expected results.
  • Get a base64 encoded PNG and use it in Jupyter notebook. Later work on python free implementation.
  • Complete line chart implementation in the leftover time.

@marcrasi For the python free implementation to display plots could you shed some light as to how swift-jupyter works, and how I can approach the problem? Or some resources I can read from regarding this?

Then I was thinking of writing some documentation for the work done till now. I think I can keep the Bar Chart work in the 1st milestone itself. I'll start working on it simultaneously finalising this PR.

marcrasi commented 5 years ago

Does plotting work in jupyter now? If so, you should make a post on https://forums.fast.ai/c/harebrain soon!

I'll respond to your question about drawing without python in a github issue.

KarthikRIyer commented 5 years ago

@marcrasi I haven't tested it in jupyter yet. I'll do that first thing today. If I should post it, on the fast.ai forum, I think it would be better if I had some basic documentation ready. So I think I should write some basic documentation and then post it. Does that seem ok?

marcrasi commented 5 years ago

Yep!

KarthikRIyer commented 5 years ago

Just out of curiosity, how does swift work in colab? Can I get plotting to work there?

BradLarson commented 5 years ago

@KarthikRIyer - Swift should work in Colab as it does in plain Jupyter, with the occasional slight lag in what Swift for TensorFlow version is used in Colab vs. a local toolchain. I think you still need to start from an existing Swift notebook as a template, since you can't create one from scratch yet, but after that it should behave like a local Jupyter notebook.

You may need to put an arbitrary tag on the project (0.0.1 or whatever) to have an initial version to refer to when pulling it into a Colab notebook. Here's a sample Fast.ai notebook that imports some Swift modules (first cell there):

https://github.com/fastai/fastai_docs/blob/master/dev_swift/00_load_data.ipynb

If you can, I'd recommend creating an examples/Notebooks directory to host example Jupyter notebooks that ship with the project, and you ignore that directory in the Package.swift (these don't need to be compiled). You should then be able to import the local project based on relative paths, instead of calling out to GitHub in those examples. Those would provide both test cases for the Jupyter support and examples for how to use it.

KarthikRIyer commented 5 years ago

@BradLarson I tried pulling SwiftPlot into colab and using it...but the display function that I added to swift-jupyter isn't available on colab.

I've added a sample notebook in a direct commit to master. I'll move it to a folder named Notebooks.

I've already added a tag 0.0.1

KarthikRIyer commented 5 years ago

@BradLarson @marcrasi could you please review this? It would be nice to post on fast.ai forum with a complete Line Graph implementation. Only this part is left.

KarthikRIyer commented 5 years ago

@BradLarson PR updated