Gad­fly: En­abling Publi­ca­tionQual­ity Plot­ting with Ju­lia

Vi­su­al­i­sa­tion of data in the form of plots is an im­por­tant re­quire­ment in to­day’s Big Data sce­nario. This ar­ti­cle in­tro­duces Gad­fly – a vi­su­al­i­sa­tion sys­tem for Ju­lia. Gad­fly en­ables de­vel­op­ers to build pub­li­ca­tion-qual­ity graph­ics in var­i­ous forms such a

OpenSource For You - - Developers -

Ju­lia is becoming in­creas­ingly pop­u­lar with de­vel­op­ers from var­i­ous do­mains, pri­mar­ily due to the sim­plic­ity and power it of­fers. One im­por­tant fea­ture pro­vided by most modern day pro­gram­ming lan­guages is the abil­ity to vi­su­alise data. As to­day’s ap­pli­ca­tions han­dle large vol­umes of data, vi­su­al­i­sa­tion be­comes a manda­tory com­po­nent.

Ju­lia is an ex­ten­si­ble pro­gram­ming lan­guage, i.e., its fea­tures can be ex­tended by adding many cus­tom pack­ages. The ex­ter­nal pack­ages that fa­cil­i­tate plot­ting in Ju­lia are listed be­low (http://ju­ down­loads/plot­ting.html):



PyPlot uses the Python call­ing fea­ture (PyCall) to di­rectly call Mat­PlotLib of Python. To use PyPlot in Ju­lia pro­grams, Python and Mat­PlotLib need to be avail­able in the sys­tem.


The fo­cus of this ar­ti­cle is to il­lus­trate the fea­tures of Gad­fly, which is based on the Wick­ham-Wilkin­son style ‘Gram­mar of Graph­ics’ in Ju­lia. De­tailed in­for­ma­tion on the Gram­mar of Graph­ics is avail­able at https://www.­son/TheGram­marOfGraph­ics/GOG. html. The gg­plot2 for R forms the ba­sis of Gad­fly. Daniel C. Jones is the pioneer in de­vel­op­ing Gad­fly. An ac­tive com­mu­nity of Ju­lia de­vel­op­ers now main­tains this pack­age (­talia/Gad­fly.jl).

Fea­tures of Gad­fly

The ma­jor fea­tures of the Gad­fly Ju­lia pack­age are listed be­low:

Gad­fly has the im­por­tant fea­ture of ren­der­ing pub­li­ca­tion qual­ity graph­ics. It en­ables ren­der­ing in var­i­ous for­mats such as SVG, PostScript, PD, etc.

It of­fers sup­port for 20+ plot types.

Gad­fly is avail­able in Ju­lia, out-of-the-box.

The fa­cil­ity to in­te­grate with DataFrames.jl is an­other key fea­ture of Gad­Fly. DataFrames.jl en­ables work­ing with tab­u­lar data in Ju­lia. It pro­vides in­ter­ac­tive fea­tures in plots such as pan­ning, zoom­ing, etc. These in­ter­ac­tiv­ity fea­tures are en­abled through snap.svg (

In­stal­la­tion of Gad­fly can be eas­ily done us­ing the fol­low­ing com­mand (at Ju­lia REPL):

ju­lia> Pkg.add(“Gad­fly”)

Af­ter suc­cess­ful in­stal­la­tion, it can be loaded as shown be­low:

Ju­lia> us­ing Gad­fly

In­stalling Gad­fly Gad­fly: A sim­ple plot

Ju­lia pro­grams can be ex­e­cuted in two dif­fer­ent ways—one is by in­stalling Ju­lia lo­cally in the sys­tem and the other is to ex­e­cute it di­rectly in Ju­li­aBox (https://ju­li­

The steps in­volved in plot­ting a sim­ple graph are il­lus­trated in this sec­tion.

Step 1: Load the Gad­fly pack­age, as fol­lows:

us­ing Gad­fly

Step 2: Load the val­ues in X and Y. In this ex­am­ple, we are load­ing 1000 random val­ues in two vari­ables— xval­ues and yval­ues.

xval­ues = rand(1000) yval­ues = rand(1000)

Step 3: Plot the graph with the Gad­fly.plot func­tion. Gad­fly.plot(x=xval­ues, y=yval­ues, Geom.point)

The out­put of Step 3 is shown in Fig­ure 2.

The fol­low­ing code se­quence gen­er­ates a line graph as shown in Fig­ure 3:

us­ing Gad­fly

Newspapers in English

Newspapers from India

© PressReader. All rights reserved.