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

Added a basic scatterplot for Magick backend #45

Merged
merged 62 commits into from Jul 12, 2019
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
01a2677
Added draw_markers, x_axis and y_axis for Magick Backend
alishdipani Apr 18, 2019
85226fc
Passed rspec test for scatter plot using Magick backend
alishdipani Apr 19, 2019
b1a0d4e
Merge branch 'master' of https://github.com/SciRuby/rubyplot
alishdipani Apr 28, 2019
34ae753
Fixed text rotation for magick backend
alishdipani Apr 28, 2019
7c70a47
Merge branch 'master' of https://github.com/SciRuby/rubyplot
alishdipani May 31, 2019
97a4023
optimized text rotation
alishdipani May 31, 2019
8393699
made a crude within_window function, does not work due to scaling in …
alishdipani Jun 1, 2019
e680fab
Improved transform function, corrected within_window function for abs…
alishdipani Jun 1, 2019
c39ed03
Improved transform function, completed within_window function
alishdipani Jun 3, 2019
c22c517
added scaling the figure according to given units
alishdipani Jun 3, 2019
9dbba0f
minor correction in within_window
alishdipani Jun 4, 2019
ec4011e
minor correction in within_window function
alishdipani Jun 4, 2019
4b10f78
allow specifying separate fill and border marker color for markers
alishdipani Jun 5, 2019
6645858
added fill_color in draw_marker function
alishdipani Jun 5, 2019
c816f7d
added new line at the end of extconf.rb
alishdipani Jun 5, 2019
5107c8d
Added border_color to draw_markers in base and scatter
alishdipani Jun 6, 2019
a69ae91
corrected draw_circle
alishdipani Jun 6, 2019
45fbd9f
Added border_color, shifted drawing borders to backend, corrected siz…
alishdipani Jun 6, 2019
847b7eb
added marker_types hash with lambdas, added modify_axes function
alishdipani Jun 8, 2019
d071b97
removed return from scale_figure and unscale_figure
alishdipani Jun 8, 2019
6b1d4d4
implemented triangle marker types
alishdipani Jun 8, 2019
6d74be9
implemented square marker types
alishdipani Jun 8, 2019
ec25027
implemented bowtie marker types
alishdipani Jun 8, 2019
b5a5c7e
implemented hourglass marker types
alishdipani Jun 8, 2019
6d387fb
implemented diamond marker types
alishdipani Jun 8, 2019
83df6be
added traingular, plus, line and omark marker types
alishdipani Jun 9, 2019
bfb4e59
corrected draw_polygon and did a minor correction in draw_text
alishdipani Jun 9, 2019
f23fa59
correction in area plot frontend
alishdipani Jun 10, 2019
a35b2f1
minor syntax improvement in base of plots
alishdipani Jun 10, 2019
378ec0d
optimized draw_rectangle for Magick backend
alishdipani Jun 10, 2019
c969b16
Merge pull request add :default color to scatter
alishdipani Jun 10, 2019
9df7195
added default X axis title and Y axis title
alishdipani Jun 11, 2019
c6f7256
added draw_lines function, minor correction in base of backend
alishdipani Jun 12, 2019
2c0f91c
correction in draw_lines
alishdipani Jun 12, 2019
e2d6541
raised exception in markers which have not been implemented yet
alishdipani Jun 17, 2019
f07c3a7
Shifted set_background_gradient to backend
alishdipani Jun 17, 2019
c7af4b7
improved exception description
alishdipani Jun 18, 2019
f67c1a1
corrected draw_line and draw_lines functions
alishdipani Jun 19, 2019
5d2760d
added draw_arrow function to magick wrapper and base of backend
alishdipani Jun 20, 2019
e7cefbd
improved variable for markers nominal factor
alishdipani Jun 21, 2019
cba898c
set default marker type to circle
alishdipani Jun 21, 2019
7e9abf2
Added hash of lambdas for line types, improved draw_lines and draw_li…
alishdipani Jun 22, 2019
e3a99ba
added default line type
alishdipani Jun 22, 2019
95f2473
Correction in Line plot, default values taken are y values
alishdipani Jun 25, 2019
36497cc
correction in bar plot, input function for spacing_ratio
alishdipani Jun 30, 2019
32f5c07
correction in multi candlestick plot
alishdipani Jul 3, 2019
b4a3698
corrected y inversion of subplots
alishdipani Jul 3, 2019
7b58780
replaced border_opacity with fill_opacity
alishdipani Jul 4, 2019
5a1f45d
instead of marker, circle is drawn to introduce opacity which is 0.5
alishdipani Jul 4, 2019
b400a3d
added a nominal scaling factor for circle
alishdipani Jul 4, 2019
370bbc2
added the frontend variable for the square axes
alishdipani Jul 6, 2019
af4b631
Added Magick backend for square axes, set line width of axes to 5 pixels
alishdipani Jul 6, 2019
4f5fa4a
plotting axes above the figures
alishdipani Jul 6, 2019
d1f1a78
corrected the function for spacing ratio in bar plot
alishdipani Jul 6, 2019
9ceac6d
added default value for marker fill color in scatter plot frontend
alishdipani Jul 6, 2019
55536cb
added variables to base of ticks
alishdipani Jul 7, 2019
7d263df
added ticks variables to the draw_x_axis and draw_y_axis functions
alishdipani Jul 7, 2019
09119e9
added minor ticks count argument to the X axis and Y axis
alishdipani Jul 7, 2019
d1bee54
added frontend for show function
alishdipani Jul 9, 2019
63ab419
added minor_ticks_count argument to draw_x_axis and draw_y_axis for GR
alishdipani Jul 9, 2019
5599b7b
added magick backend for show function
alishdipani Jul 9, 2019
f918e9c
added the show function for GR backend
alishdipani Jul 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions ext/grruby/extconf.rb
@@ -1,6 +1,6 @@
require 'mkmf'

$CFLAGS << ' -I/usr/local/gr/include '
$LDFLAGS << ' -L/usr/local/gr/lib -lGR -lm -Wl,-rpath,/usr/local/gr/lib '
$CFLAGS << ' -I/home/sameer/Downloads/gr/include '
$LDFLAGS << ' -L/home/sameer/Downloads/gr/lib -lGR -lm -Wl,-rpath,/home/sameer/Downloads/gr/lib '

create_makefile('grruby/grruby')
1 change: 1 addition & 0 deletions lib/rubyplot/artist/axis/x_axis.rb
Expand Up @@ -21,6 +21,7 @@ def draw
private

def configure_title
@title = 'X axis' if @title == ''
@texts << Rubyplot::Artist::Text.new(
@title,
self,
Expand Down
3 changes: 2 additions & 1 deletion lib/rubyplot/artist/axis/y_axis.rb
Expand Up @@ -11,14 +11,15 @@ def draw
origin: @axes.origin[1],
major_ticks: @major_ticks,
minor_ticks: @minor_ticks,
major_ticks_count: @major_ticks_count
major_ticks_count: @major_ticks_count
)
@texts.each(&:draw)
end

private

def configure_title
@title = 'Y axis' if @title == ''
@texts << Rubyplot::Artist::Text.new(
@title,
self,
Expand Down
10 changes: 0 additions & 10 deletions lib/rubyplot/artist/figure.rb
Expand Up @@ -91,16 +91,6 @@ def add_subplot!(nrow, ncol)
@subplots[nrow][ncol]
end

def set_background_gradient
Rubyplot.backend.set_base_image_gradient(
Rubyplot::Color::COLOR_INDEX[@theme_options[:background_colors][0]],
Rubyplot::Color::COLOR_INDEX[@theme_options[:background_colors][1]],
@width,
@height,
@theme_options[:background_direction]
)
end

# Draw on a canvas and output to a file.
#
# @param file_name [String] File name to output to.
Expand Down
8 changes: 4 additions & 4 deletions lib/rubyplot/artist/plot/area.rb
Expand Up @@ -6,12 +6,12 @@ class Area < Artist::Plot::Base

def initialize(*)
super
@sort_data = true
@sort_data = false
end

def data x_values, y_values=[]
y_values = Array.new(x_values.size) { |i| i } if y_values.empty?
x_values.sort! if @sort_data
def data y_values, x_values=[]
x_values = Array.new(y_values.size) { |i| i } if x_values.empty?
y_values.sort! if @sort_data
super(x_values, y_values)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rubyplot/artist/plot/base.rb
Expand Up @@ -34,7 +34,7 @@ def label=(label)
@data[:label] = label
end

def color= color
def color=(color)
@data[:color] = color
end

Expand Down
4 changes: 2 additions & 2 deletions lib/rubyplot/artist/plot/line.rb
Expand Up @@ -16,8 +16,8 @@ def initialize(*)
@line_color = :black
end

def data(x_values, y_values=[])
y_values = Array.new(x_values.size) { |i| i } if y_values.empty?
def data(y_values, x_values=[])
x_values = Array.new(y_values.size) { |i| i } if x_values.empty?
super x_values, y_values
end

Expand Down
3 changes: 2 additions & 1 deletion lib/rubyplot/artist/plot/scatter.rb
Expand Up @@ -41,7 +41,8 @@ def draw
x: @data[:x_values],
y: @data[:y_values],
type: @marker_type,
fill_color: color,
fill_color: @marker_fill_color,
border_color: @marker_border_color,
size: [@marker_size] * @data[:x_values].size
)
end
Expand Down
30 changes: 17 additions & 13 deletions lib/rubyplot/backend/base.rb
Expand Up @@ -22,8 +22,8 @@ class Base
# @param valign [Symbol] Vertical alignment of the text from Artist::Text::VAlignment
def draw_text(text,color:,font: nil,size:,
font_weight: nil, halign: nil, valign: nil,
abs_x:, abs_y:,rotation: nil, stroke: nil)
raise NotImplementedError, "not implemented for #{self}."
abs_x:, abs_y:,rotation: nil, stroke: nil, abs: false)
raise NotImplementedError, "not implemented for #{__method__}."
end

# Draw a rectangle with optional fill.
Expand All @@ -33,8 +33,8 @@ def draw_text(text,color:,font: nil,size:,
# @param x2 [Numeric] Upper right X co-ordinate.
# @param x2 [Numeric] Upper right Y co-ordinate.
def draw_rectangle(x1:,y1:,x2:,y2:, border_color: nil, fill_color: nil,
border_width: nil, border_type: nil)
raise NotImplementedError, "not implemented for #{self}."
border_width: nil, border_type: nil, abs: false)
raise NotImplementedError, "not implemented for #{__method__}."
end

# Draw multiple markers as specified by co-ordinates.
Expand All @@ -44,14 +44,14 @@ def draw_rectangle(x1:,y1:,x2:,y2:, border_color: nil, fill_color: nil,
# @param marker_type [Symbol] A marker type from Rubyplot::MARKERS.
# @param marker_color [Symbol] A color from Rubyplot::Color.
# @param marker_size [Numeric] Size of the marker.
def draw_markers(x:, y:, marker_type:, marker_color:, marker_size:)
raise NotImplementedError, "not implemented for #{self}."
def draw_markers(x:, y:, type:, fill_color:, border_color:, size:)
raise NotImplementedError, "not implemented for #{__method__}."
end

# Draw a circle.n
def draw_circle(x:, y:, radius:, border_width:, border_color:, border_type:,
fill_color:, fill_opacity:)
raise NotImplementedError, "not implemented for #{self}."
raise NotImplementedError, "not implemented for #{__method__}."
end

# Draw a polygon and fill it with color. Co-ordinates are specified in (x,y)
Expand All @@ -62,23 +62,27 @@ def draw_circle(x:, y:, radius:, border_width:, border_color:, border_type:,
# @param border_width [Numeric] Widht of the border.
def draw_polygon(x:, y:, border_width:, border_type:, border_color:, fill_color:,
fill_opacity:)
raise NotImplementedError, "not implemented for #{self}."
raise NotImplementedError, "not implemented for #{__method__}."
end

def draw_lines(x:, y:, width:, type:, color:)
raise NotImplementedError, "not implemented for #{self}."
def draw_lines(x:, y:, width:, type:, color:, opacity:)
raise NotImplementedError, "not implemented for #{__method__}."
end

def draw_arrow(x1:, y1:, x2:, y2:, size:, style:)
raise NotImplementedError, "not implemented for #{__method__}."
end

def init_output_device file_name, device: :file
raise NotImplementedError, "not implemented for #{self}."
raise NotImplementedError, "not implemented for #{__method__}."
end

def draw_x_axis(minor_ticks:, origin:, major_ticks:, major_ticks_count:)
raise NotImplementedError, "not implemented for #{self}."
raise NotImplementedError, "not implemented for #{__method__}."
end

def draw_y_axis(minor_ticks:, origin:, major_ticks:, major_ticks_count:)
raise NotImplementedError, "not implemented for #{self}."
raise NotImplementedError, "not implemented for #{__method__}."
end
end # class Base
end # module Backend
Expand Down