[RUBYPLOT-GSOC][DAILY][7 June] Implementing different types of markers
Planned progress
Adding different types of markers
Progress
Had a weekly meeting with @v0dro to give updates and discussed some design decisions
Implemented a hash with lambdas for different types of markers
removed return from scale_figure and unscale_figure
added modify_draw function which modifies a draw object (or an array of draw objects) when required only for executing a block i.e. the object is modified and then after execution of the blog, the object is returned to its original state.
Scaling, rotation and translation is allowed in modify_draw
Problems
Implementing hash with lambdas is better than making a big method but the hash will still be very big and is the best option considering the number of different types of markers (around 35)(other options are creating helper functions or creating a module )
Shifting set_background_gradient is to be done
modify_draw function will be a little tough to understand for new developers but is a good design decision considering scalability.
The hash for marker types is too big but is important.
The remaining marker types involve too much coordinate geometry, I have asked for suggestions in the ImageMagick discourse. If nothing else is possible I will implement it using geometry (by plotting multiple lines by giving points as inputs calculated relative to x and y coordinate of the marker)
Found a major bug in area plot frontend and found a way to correct it
Did a minor correction in draw_text → not draw anything when the text is not given
Improved the blogs
Checked multiple subplots for Magick backend and they’re working (tested through a 2x2 grid with all the plots being scatter plots) (I have not tested rspec tests as they have candle-stick plots which have not yet been checked for Magick backend)
Problems
I could not complete the blogs today but I will make sure to complete them by Monday and will post my weekly progress(week 1 and 2) and the blog links on the Mailing List.
Although I corrected the bug, the delta for the area plot test is around 4500 and hence the test is not being passed Magick backend, it passes for GR backend. The plot for the test looks correct but the test is not passed. Here are the images for Magick and GR backend for an area plot for the data [25, 36, 86, 39, 25, 31, 79, 88] (corresponding to the rspec test):
If texts are not given to draw_text function in GR backend then garbage value is printed (I fixed this magick backend by adding a simple condition that execute the code in the draw_text function only when text is given i.e. added
unless text.empty?
)
In scatter plot, the marker_fill_color has no default value and it gives an error if it is not set.
Should the square in the legend box describing the colour of the data have a border?(preferably black) as if I set the fill colour to white, the square is not visible as the background in Magick backend is white
While plotting multiple subplots, if a subplots is below another subplot then the x axis title of the upper subplot and title of the lower subplot overlap
Does x_axis.rb need
require_relative ‘base’
as it already inherits the base?
The constructor of x_axis.rb is
def initialize axes
and that of y_axis.rb is
def initialize(*)
and their parent class has
def initialize axes
So, I think that the syntax for y_axis should be changed to avoid confusion
The default title for X axis and Y axis is no text, would ‘X axis’ and ‘Y axis’ as the title by default be better?
in GR backend, in scatter plot the markers are drawn behind the X and Y axes, should it be in front of the axes? (If yes, can it be done?)
Good job so far. Can you get all your work to a mergeable state so that I can merge your PR into master by the time you go on leave to get your visa? That way we will have a good way to gauge progress w.r.t the rest of the library when I work on the GR part and help us sync our work better.
I’ll start reviewing your already open PR so that you can make changes accordingly. Also, I need to see your blog ASAP. Its been delayed already.
Here’s replies to the problems you pointed out:
Area plot bug: The data should not be sorted
Works. Shouldn’t have sorted it in the first place.
Although I corrected the bug, the delta for the area plot test is around 4500
I suspect its because of the opacity that the comparison between the pixels goes wrong. Might there be a way around it?
The require statement loads the file that contains the Base class which Axes inherits from.
Will fix. Thanks.
Hmmm works. That would be a good addition. Can you open an issue for this so that I can implement in the GR backend as well?
Yes.
I’m sure whether it can done. Maybe can try plotting the axes after plotting the elements within the plot. Anyway the need for this will be mitigated if we take 5% extra distance on each of the axes.
Thanks! I will be leaving for the Intel summit on 13th (and will be unavailable till 16th), I haven’t got the appointment date for my visa yet as I have not applied for it due to some delayed paperwork (I will let you know the dates as soon as I get it)
The PR is mergeable you can review it and merge it (the only temporary change is set_background_gradient function which I will look into later)
Completed the scatter plot example blog, link: https://alishdipani.github.io/gsoc2019/2019/06/06/The-Scatter-plot-example/ . This blog contains a scatter plot example and the code walkthrough and explanation of the whole codebase for Magick backend. (@v0dro can you please go through this and the introductory blog and suggest if any changes? )
Tested the bubble plots, the plot looks fine but tests are failed (delta is too much), the figure saved for the example for both backends:
GR:
I have already explained all the functions which I implemented in The scatter plot example blog, I will make a separate blog and explain the functions again so that my progress is shown.
Various test in the bar plot, area plot and bubble plot fail because of the delta being too much but the plots look fine. The deltas are highly dependent on the colour used in the plots and some tests pass for light colours like yellow or white but fail for dark colours like green or black. @v0dro any idea why this might be happening? and any suggestions to improve this?
Should bubbles in bubble plot have a little less opacity so that if bubbles overlap, the visibility is more?
If no label is given to the plot then the GR backend draws incorrect text (It should draw nothing). Maybe this will fix if the condition of the empty string given is solved as discussed previously.
I have been invited to an Intel summit held at Bangalore as I am an Intel student ambassador. I will be attending the summit from 13th-16th June and will resume the work from 17th June.
Sorry for the unavailability.
I like the details in your blog post. However in its current form its quite difficult to read because you’re diving directly into very deep technical details.
Can you add an ‘introduction’ paragraph that will serve as an overall introduction to the entire blog post? You can a table contents too and refer to that in your introduction. Something on the lines of ‘I have written so and so features and you can find this detail here and that detail there’. Like the introductory chapter of a reference book.
Here’s some more feedback regarding the blog post:
As an example, in the Setting Output Device part of the post, you’ve a detailed explanation of the function of each within the method init_output_device. But what is missing here is the ‘purpose’ of each line. I can see that you’re creating three Magick::Draw objects. But WHY create three objects? What were the underlying design decisions that lead to creation of three objects instead of just one? These things are much more interesting to someone reading your post to get a technical overview. They also serve as guidelines later when a developer is wondering about the purpose of the code.
Another example is that we do not use the MATLAB notation for creating subplots (which is used by matplotlib). Would be great if you can write the reasons for that too.
Also explain why you do the text rotation in Magick the way you do.
Please make such updates to your post before moving on to the next one.
Added exception to markers which are not yet implemented
Problems
I tested subplots (all scatter plots) for Magick and GR backends and found a bug in Magick subplots, the Rubyplot coordinates are not flipped in within_window. Example
[RUBYPLOT-GSOC][DAILY][18 June] Getting back on track
Planned progress
Checking Line plot
Progress
Corrected draw_line function
Updated draw_lines function
Passed all the tests for Line plot
Problems
GR backend does not have line colours
Magick backend colours all the lines same as the last colour given
Line types have not been implemented
A potential problem in Frontend of Line plot: When only one array is given to the Line plot, it considers it as x values and y values are adjusted accordingly whereas in Matplotlib’s plot function, this data is considered as y values and x values are adjusted accordingly. So, is it correct @v0dro?
What are arrows? They are not drawn in GR backend either? The x1,x2, y1,y2 are said to be coordinates of head and tail of the arrow, what does the tail refer to? @v0dro please let me know about this
Magick backend plots the lines beyond the axes (outside plotting window)