Planned Progress
Correcting the transform function to improve the plot.
Progress
Revised the codebase.
Tried to correct the transform function and realised that within_window function needs to be done first.
Optimized text rotation by plotting it only when write function is called. (the coordinate system is translated to its original value before proceeding for next text) (Will explain text rotation in the next blog)
Problems
Rubyplot needs a standardised unit system as GR and Magick both use various units for points,
text, etc. This is a major challenge which needs to be solved. This may be solved by using the figsize_unit argument in the figure, I will look into it further later.
Magick backend lacks a within_window function which is needed for further development since it has no inbuilt function like setviewport, a function will have to be created for solving this. This will have to be done first before proceeding further.
Plans
(For next 4 days) I will find a way to create the within_window function and then proceed to correct transform function and implementing major and minor ticks in the X and Y axes.
[RUBYPLOT-GSOC][DAILY][1 June] Setting up basics for the backend
Planned Progress
Implementing ticks in X and Y axes.
Progress
Created the within_window function only for abs = false.
Corrected the transform function.
The scatter plot looks like this currently(with canvas height and width 500 pixels) :
(Legend box and text are missing due to incomplete within_window function (for abs = true))
Problems
Understanding the different units used is confusing, I struggled a lot to understand it.
This is mainly due to scaling issues which have not yet been tackled, I will work on that after completion of the within_window function.
Due to lack of setviewport and setwindow functions in Magick, I found a way to implement them using translating and scaling (and then rescaling and retranslating to original coordinates after calling the block), I feel doing this is inefficient but is the only way to implement it.
Plans
After implementing within_window for abs = true, the basic plot will be ready after which I will implement ticks (by end of 4th June)
You can name the translating functions the same as they are in GR so as to keep the code understandable and uniform.
For example put the Magick::setviewport function inside a module MagickWrapper::Helpers and put all these functions in there which help you make Magick behave more like a plotting library than simply an image manipulation tool.
I have combined setwindow and setviewport functions, separating them would be a difficult task as it would require scaling and translating twice(will explain in the next blog). For translation, magick’s inbuilt function translate is used and there’s no separate function for translation.
[RUBYPLOT-GSOC][DAILY][3 June] Completed setting up basics for the backend
Planned Progress
researching on and creating within_window function
Progress
Completed within_window function for abs = true by modifying the transform function.
Corrected scaling issues by changing canvas height and width when require based on figsize_unit variable (cm, inch or pixel).
Found and corrected a small bug in scatter plot: For setting the colour of markers marker_color function should be used and currently doing this does not change the colour in the legend box and so found a way by changing color variable in data to fix the bug (waiting for approval from @v0dro since it is a change in the frontend )
Currently, the scatter plot looks like this (For default size 40 cm and colour of markers plum purple):
Scaling in this way is limited to magick backend and not for GR and so for consistency may be a different method can be found (or a similar method can be found for GR)
implementing within_window function with abs = true (i.e. plot units in rubyplot coordinates) was done by improving transform_x and tranform_y function so as they can transform rubyplot coordinates (abs = true) and plot data coordinates (abs = false) to pixel values.
There was a small bug in scatter plot (refer to point 3 in progress)
Plans
Implementing ticks for Magick backend (by EOD 4th June) and writing a blog after this.
I don’t entirely understand what you mean by ‘scaling in this way is limited to magick bacend and not for GR’.
Can you please explain?
Also, what is your approach for the XTicks? GR does it with a callback but I think that is a very limiting approach if all you want to do is specify your ticks in an array.
Ah I see. But how do you change the ‘view’ on the canvas on which you are plotting? Do you do this at the same time as setting the co-ordinates of that view?
The viewports are very useful when working with multiple subplots.
The only possible way I think in magick backend is by specifying the ticks in an array and then at the time of plotting x axis, iterate through the array and make lines at the point where tick is required. I am trying this approach currently.
Planned Progress
Completing the within_window function
Progress
Found a bug in frontend for adding subplots, in the function add_subplot! the array should use nrow -1 and ncol - 1 as the array is 0-indexed and the numbering for subplots start with 1.
Updated my website (enables disqus) for future blogs.
Revised the within_window function and corrected a small bug (had used bottom margins instead of top margins) (magick has its origin at top left corner)
Problems
While implementing ticks, where should the ticks be placed and how does the GR backend make them is unclear? (will discuss with @v0dro)
The only way to make ticks in magick backend is to make small lines where tick is required.
usage of XTick and YTick object is unclear and why is(x/y)_minor_ticks_count not passed in axes_map? (alternatively where is (x/y)_major_ticks_count) used?
Plans
Implementing ticks will take a lot of time as it (maybe) requires changes in frontend and major design decisions. I will work on ticks parallelly with the daily planned tasks until it is completed (if I am not able to complete in decided time)
Improving my introductory blog (adding how does the library work)
Writing a blog for the progress till 6th July EOD (i.e. setting up plot basics before moving on to plot-specific tasks)
The window of canvas is the base_image itself. For drawing shapes/text/axes 3 Magick::Draw objects are used which are named draw, text and axes. So when I want to change the view i.e. the area where to plot I translate the origin (initially upper left corner) of all these by left_spacing (of figure) + left_margin (of axes) and top_spacing (of figure) + top_margin (of axes) and after this translation these are scaled in the required proportion (this scaling scales all the pixel coordinate values) and so all the drawing now is done in the required space.
Lets talk about the ticks in this week’s meeting. I had implemented ticks in Magick before, and you can use that code as reference. However I’m not very happy with the way it was previously implemented and you’ll need to think of new way of implementing it such that it fits into the new front end.
Started writing a blog for explaining a scatter plot example in detail with the code for new developers to get started easily, this blog will be followed by a blog discussing functions I implemented and the design decisions taken, link: https://alishdipani.github.io/gsoc2019/2019/06/06/The-Scatter-plot-example/
Corrected base(for backend) and scatter by adding border_color
Corrected draw_circle function
Shifted drawing markers in draw_markers to the backend
Added a nominal factor to be multiplied by the size of the markers, in GR the nominal factor is the nominal size generated on the graphics device, I hardcoded the value for Magick backend (I have set it to 15 as it seemed good to me, @v0dro please suggest if any changes (will discuss this in the weekly call))
Implemented circle and plus markers
Problems
The scatter plot example blog is big and will take 1-2 more days.
the nominal factor for marker size is set to 15 (see the 6th point in progress), should it be changed?
Implementing different types of markers will make the draw_marker function very big, should helper functions be created for every marker or one for each marker? The helper functions will also be big anyway if created.
Plans
Completing the scatter plot example blog
Writing the setting up basics blog after the example blog