ggbash::theme2()
as an enhanced version of ggplot2::theme()
.+
signs in terminal modesize = 3 + .5
and Good: size=3+.5
)
This is because without parentheses and commas, there are almost
no clues that differentiate between "ggplot2 plus" (connecting
layers) and "R's plus" (an operator for addition).
The hope is that in NSE mode ggbash can still include whitespaces
between aes names and values. I hope this would not lead to users'
frustration.p
should return p
instead of price
,
even if the latter comes first)%>%
and aes() case.
(dot) in parsing rules of variable names%>%
operator.
operator means,
so the contents of .
have to be properly set in temporary
variable (ggbash_piped
) in ggbash() and exec_ggbash()...density..
or ..prop..
(four dots variables)binwidth = c(1, 1)
group=1
stat_bin_hex
:
in theme elements names and /
in save_ggplot arguments. This is because or R's language restriction for more handy NSE. This supersede grammar rules determined in v0.2 change.size
by sz
)legend.key
by l.key
, or legend.box.background
by l.b.b
)ggbash()
arguments
should increase complexity
and might significantly slows down the development process.
As a remedy, ggbash()
now returns a ggplot2 object (not a string) by ggbash()
,
and can chain other geom_ or theme_ objects by the normal +
operator in ggplot2.ggbash("gg(iris, Sepal.W, Sepal.L) + point(col=Spec, size=5) ") + geom_text_repel(aes(label=Species))
bin2d bins=10
geom_countour
, geom_point
, and so onmethod="lm"
in geom_smooth, binwidth=30
in geom_histogram)
by get_stat_params
weight
in geom_bargeom_abline
and geom_bar
legend.position = ("none")
or
panel.ontop = (TRUE)
)...element_text
is
placed before the current token.gg mtcars + text mpg cyl
check_overlap
, etc.)From this v0.3.0, ggbash incorporates a powerful feature called fixit. It's inspired from a modern C++ compiler clang's Fix-It Hints. Now when ggbash users input a string which contains some typos, ggbash gives users useful information on what might be needed to fix the compile error.
gg iris + point Sepl.W Sepal.L
,
ggbash gives Column name not found
error
and also displays that the most similar column names are
Sepal.Width, Species, Sepal.Length, Petal.Width, Petal.Length
,
in this order.
This could significantly reduce the learning cost of ggplot2 and ggbash,
having a possibility of making ggbash suitable for new ggplot2 users
as well as its heavy users.axis.ticks.length = 10 cm
into grid::unit(10, 'cm')
in theme()
=
theme_bw()
, theme_classic()
, ...) works by + theme bw
or + theme_bw
lexer.R
and parser.R
into ggplot2-compiler.R
ggplot2::theme()
is a powerful function that tweaks a lot of plot elements.
In this v0.2 release, most of the functions of theme
are implemented.
It might need more test cases because of a lot of possibilities (such as a character variable), so the next a few weeks will be for fixing various bugs.
ggplot2:::.element_tree
Implementation of theme
requires names and classes of
theme elements like axis.text.x
or legend.title
.
As far as I researched, using ggplot2:::.element_tree
seemed to be the best way
to get those classes such as element_text
or character
.
But anyone can see in get_all_theme_aes
implementation,
this does not look a clean way to achieve that.
theme
One design decision I made and am not certain is to use :
for separating theme's elements.
One example is:
theme(text = element_text(size=5, face="bold"), line = element_line(linetype='dotted'))
theme text: size=5 face="bold" line: linetype='dotted'
The other ways I considered were as follows:
theme text = size=5 face="bold" line = linetype="dotted" # nested =
theme text := size=5 face="bold" line := linetype="dotted" # new operator :=
theme text(size=5, face="bold") line(linetype="dotted") # function-like parentheses
theme text(size=5 face="bold") line(linetype="dotted") # without commas
I could not decide which way is the best -- for me, all of the above options look violated principle of least astonishment.
But the implemented one lookedthe most intuitive, easy-to-learn, and easy-to-read at least among them. This decision will be easily changed by a more appealing alternative.
In the previous v0.1.0, all the tokenization/parsing/evaluation are interlaced, leading to possible hard maintainance and less readability.
In this v0.1.1 release, leveraging rly library's functionalities, most of the tokenization and parsing are separated into Ggplot2Lexer and Ggplot2Parser R6 objects.
Those two R6 objects are modularized just for ggplot2 grammars. i.e. tokenization and parsing of builtin ggbash commands such as copy, echo, or rm are still done by split_by_pipe() procedures.
This change resulted in removals of drawgg() and build_geom(), and all done in rly branch.
Adding new ggproto objects such as Scale or Coord now become adding new tokens in GGPLOT2_TOKENS and adding corresponding prodcution rules in Ggplot2Parser. This would enable much faster and less error-prone development process.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.