Skip to content

Commit dd16892

Browse files
committed
Merge pull request #121 from ropensci/pd-ggplot-default-axis
ggplot: show ticks by default
2 parents 5c043ba + 660524b commit dd16892

File tree

184 files changed

+514
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+514
-9
lines changed

R/ggplotly.R

+17-9
Original file line numberDiff line numberDiff line change
@@ -273,13 +273,6 @@ gg2list <- function(p){
273273
## These numeric length variables are not easily convertible.
274274
##ax.list$gridwidth <- as.numeric(theme.pars$panel.grid.major$size)
275275
##ax.list$ticklen <- as.numeric(theme.pars$axis.ticks.length)
276-
ax.list$tickwidth <- theme.pars$axis.ticks$size
277-
tick.text.name <- s("axis.text.%s")
278-
ax.list$showticklabels <- !is.blank(tick.text.name)
279-
tick.text <- e(tick.text.name)
280-
ax.list$tickangle <- if(is.numeric(tick.text$angle)){
281-
-tick.text$angle
282-
}
283276

284277
theme2font <- function(text){
285278
if(!is.null(text)){
@@ -288,6 +281,23 @@ gg2list <- function(p){
288281
color=toRGB(text$colour))
289282
}
290283
}
284+
# Ticks.
285+
if (is.blank("axis.ticks")) {
286+
ax.list$ticks <- ""
287+
} else if (is.blank(s("axis.ticks.%s"))) {
288+
ax.list$ticks <- ""
289+
} else {
290+
ax.list$ticks <- "outside" # by default ggplot2 plots have ticks
291+
}
292+
ax.list$tickwidth <- theme.pars$axis.ticks$size
293+
tick.text.name <- s("axis.text.%s")
294+
ax.list$showticklabels <- !is.blank(tick.text.name)
295+
tick.text <- e(tick.text.name)
296+
if (is.numeric(tick.text$angle)) {
297+
ax.list$tickangle <- -tick.text$angle
298+
}
299+
ax.list$tickfont <- theme2font(tick.text)
300+
291301
## Translate axes labels.
292302
scale.i <- which(p$scales$find(xy))
293303
ax.list$title <- if(length(scale.i)){
@@ -300,7 +310,6 @@ gg2list <- function(p){
300310
}else{
301311
p$labels[[xy]]
302312
}
303-
ax.list$tickfont <- theme2font(tick.text)
304313
title.text <- e(s("axis.title.%s"))
305314
ax.list$titlefont <- theme2font(title.text)
306315
ax.list$type <- if(misc$is.continuous[[xy]]){
@@ -319,7 +328,6 @@ gg2list <- function(p){
319328
## Some other params that we used in animint but we don't yet
320329
## translate to plotly:
321330
!is.blank(s("axis.line.%s"))
322-
!is.blank(s("axis.ticks.%s"))
323331
layout[[s("%saxis")]] <- ax.list
324332
}
325333

57.3 KB
280 Bytes

tests/testthat/test-ggplot-abline.json

+2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"type": "linear",
6868
"showgrid": true,
6969
"showline": false,
70+
"ticks": "outside",
7071
"showticklabels": true,
7172
"tickcolor": "rgb(127,127,127)",
7273
"gridcolor": "rgb(255,255,255)"
@@ -76,6 +77,7 @@
7677
"type": "linear",
7778
"showgrid": true,
7879
"showline": false,
80+
"ticks": "outside",
7981
"showticklabels": true,
8082
"tickcolor": "rgb(127,127,127)",
8183
"gridcolor": "rgb(255,255,255)"
58.9 KB
367 Bytes

tests/testthat/test-ggplot-area.json

+2
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@
222222
"type": "linear",
223223
"showgrid": true,
224224
"showline": false,
225+
"ticks": "outside",
225226
"showticklabels": true,
226227
"tickcolor": "rgb(127,127,127)",
227228
"gridcolor": "rgb(255,255,255)"
@@ -231,6 +232,7 @@
231232
"type": "linear",
232233
"showgrid": true,
233234
"showline": false,
235+
"ticks": "outside",
234236
"showticklabels": true,
235237
"tickcolor": "rgb(127,127,127)",
236238
"gridcolor": "rgb(255,255,255)"

tests/testthat/test-ggplot-bar-category-names.json

+2
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
"type": "category",
122122
"showgrid": true,
123123
"showline": false,
124+
"ticks": "outside",
124125
"showticklabels": true,
125126
"tickcolor": "rgb(127,127,127)",
126127
"gridcolor": "rgb(255,255,255)"
@@ -130,6 +131,7 @@
130131
"type": "linear",
131132
"showgrid": true,
132133
"showline": false,
134+
"ticks": "outside",
133135
"showticklabels": true,
134136
"tickcolor": "rgb(127,127,127)",
135137
"gridcolor": "rgb(255,255,255)"
51.3 KB
335 Bytes

tests/testthat/test-ggplot-bar-dates.json

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"type": "date",
4646
"showgrid": true,
4747
"showline": false,
48+
"ticks": "outside",
4849
"showticklabels": true,
4950
"tickcolor": "rgb(127,127,127)",
5051
"gridcolor": "rgb(255,255,255)"
@@ -54,6 +55,7 @@
5455
"type": "linear",
5556
"showgrid": true,
5657
"showline": false,
58+
"ticks": "outside",
5759
"showticklabels": true,
5860
"tickcolor": "rgb(127,127,127)",
5961
"gridcolor": "rgb(255,255,255)"
52.1 KB
247 Bytes

tests/testthat/test-ggplot-bar-dodge.json

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"type": "category",
4646
"showgrid": true,
4747
"showline": false,
48+
"ticks": "outside",
4849
"showticklabels": true,
4950
"tickcolor": "rgb(127,127,127)",
5051
"gridcolor": "rgb(255,255,255)"
@@ -54,6 +55,7 @@
5455
"type": "linear",
5556
"showgrid": true,
5657
"showline": false,
58+
"ticks": "outside",
5759
"showticklabels": true,
5860
"tickcolor": "rgb(127,127,127)",
5961
"gridcolor": "rgb(255,255,255)"

tests/testthat/test-ggplot-bar-factor-category.json

+2
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
"type": "category",
131131
"showgrid": true,
132132
"showline": false,
133+
"ticks": "outside",
133134
"showticklabels": true,
134135
"tickcolor": "rgb(127,127,127)",
135136
"gridcolor": "rgb(255,255,255)"
@@ -139,6 +140,7 @@
139140
"type": "linear",
140141
"showgrid": true,
141142
"showline": false,
143+
"ticks": "outside",
142144
"showticklabels": true,
143145
"tickcolor": "rgb(127,127,127)",
144146
"gridcolor": "rgb(255,255,255)"
256 Bytes

tests/testthat/test-ggplot-bar-identity.json

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"type": "category",
4646
"showgrid": true,
4747
"showline": false,
48+
"ticks": "outside",
4849
"showticklabels": true,
4950
"tickcolor": "rgb(127,127,127)",
5051
"gridcolor": "rgb(255,255,255)"
@@ -54,6 +55,7 @@
5455
"type": "linear",
5556
"showgrid": true,
5657
"showline": false,
58+
"ticks": "outside",
5759
"showticklabels": true,
5860
"tickcolor": "rgb(127,127,127)",
5961
"gridcolor": "rgb(255,255,255)"
51.9 KB
239 Bytes

tests/testthat/test-ggplot-bar-stack.json

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"type": "category",
4646
"showgrid": true,
4747
"showline": false,
48+
"ticks": "outside",
4849
"showticklabels": true,
4950
"tickcolor": "rgb(127,127,127)",
5051
"gridcolor": "rgb(255,255,255)"
@@ -54,6 +55,7 @@
5455
"type": "linear",
5556
"showgrid": true,
5657
"showline": false,
58+
"ticks": "outside",
5759
"showticklabels": true,
5860
"tickcolor": "rgb(127,127,127)",
5961
"gridcolor": "rgb(255,255,255)"

tests/testthat/test-ggplot-boxplot-datetime.json

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"type": "linear",
2727
"showgrid": true,
2828
"showline": false,
29+
"ticks": "outside",
2930
"showticklabels": true,
3031
"tickcolor": "rgb(127,127,127)",
3132
"gridcolor": "rgb(255,255,255)"
@@ -35,6 +36,7 @@
3536
"type": "date",
3637
"showgrid": true,
3738
"showline": false,
39+
"ticks": "outside",
3840
"showticklabels": true,
3941
"tickcolor": "rgb(127,127,127)",
4042
"gridcolor": "rgb(255,255,255)"
56.7 KB
218 Bytes

tests/testthat/test-ggplot-boxplot.json

+2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"type": "category",
6868
"showgrid": true,
6969
"showline": false,
70+
"ticks": "outside",
7071
"showticklabels": true,
7172
"tickcolor": "rgb(127,127,127)",
7273
"gridcolor": "rgb(255,255,255)"
@@ -76,6 +77,7 @@
7677
"type": "linear",
7778
"showgrid": true,
7879
"showline": false,
80+
"ticks": "outside",
7981
"showticklabels": true,
8082
"tickcolor": "rgb(127,127,127)",
8183
"gridcolor": "rgb(255,255,255)"
98.8 KB

tests/testthat/test-ggplot-contour.json

+2
Original file line numberDiff line numberDiff line change
@@ -5609,6 +5609,7 @@
56095609
"type": "linear",
56105610
"showgrid": true,
56115611
"showline": false,
5612+
"ticks": "outside",
56125613
"showticklabels": true,
56135614
"tickcolor": "rgb(127,127,127)",
56145615
"gridcolor": "rgb(255,255,255)"
@@ -5618,6 +5619,7 @@
56185619
"type": "linear",
56195620
"showgrid": true,
56205621
"showline": false,
5622+
"ticks": "outside",
56215623
"showticklabels": true,
56225624
"tickcolor": "rgb(127,127,127)",
56235625
"gridcolor": "rgb(255,255,255)"

tests/testthat/test-ggplot-date-class-Date.json

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"type": "date",
3535
"showgrid": true,
3636
"showline": false,
37+
"ticks": "outside",
3738
"showticklabels": true,
3839
"tickcolor": "rgb(127,127,127)",
3940
"gridcolor": "rgb(255,255,255)"
@@ -43,6 +44,7 @@
4344
"type": "linear",
4445
"showgrid": true,
4546
"showline": false,
47+
"ticks": "outside",
4648
"showticklabels": true,
4749
"tickcolor": "rgb(127,127,127)",
4850
"gridcolor": "rgb(255,255,255)"

tests/testthat/test-ggplot-date-irregular-time-series.json

+2
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
"type": "date",
129129
"showgrid": true,
130130
"showline": false,
131+
"ticks": "outside",
131132
"showticklabels": true,
132133
"tickcolor": "rgb(127,127,127)",
133134
"gridcolor": "rgb(255,255,255)"
@@ -137,6 +138,7 @@
137138
"type": "linear",
138139
"showgrid": true,
139140
"showline": false,
141+
"ticks": "outside",
140142
"showticklabels": true,
141143
"tickcolor": "rgb(127,127,127)",
142144
"gridcolor": "rgb(255,255,255)"
298 Bytes

tests/testthat/test-ggplot-date-strings.json

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"type": "date",
5454
"showgrid": true,
5555
"showline": false,
56+
"ticks": "outside",
5657
"showticklabels": true,
5758
"tickcolor": "rgb(127,127,127)",
5859
"gridcolor": "rgb(255,255,255)"
@@ -62,6 +63,7 @@
6263
"type": "linear",
6364
"showgrid": true,
6465
"showline": false,
66+
"ticks": "outside",
6567
"showticklabels": true,
6668
"tickcolor": "rgb(127,127,127)",
6769
"gridcolor": "rgb(255,255,255)"
75.9 KB
470 Bytes

tests/testthat/test-ggplot-density.json

+2
Original file line numberDiff line numberDiff line change
@@ -58809,6 +58809,7 @@
5880958809
"type": "linear",
5881058810
"showgrid": true,
5881158811
"showline": false,
58812+
"ticks": "outside",
5881258813
"showticklabels": true,
5881358814
"tickcolor": "rgb(127,127,127)",
5881458815
"gridcolor": "rgb(255,255,255)"
@@ -58818,6 +58819,7 @@
5881858819
"type": "linear",
5881958820
"showgrid": true,
5882058821
"showline": false,
58822+
"ticks": "outside",
5882158823
"showticklabels": true,
5882258824
"tickcolor": "rgb(127,127,127)",
5882358825
"gridcolor": "rgb(255,255,255)"
92.7 KB

tests/testthat/test-ggplot-density2d.json

+2
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,7 @@
628628
"type": "linear",
629629
"showgrid": true,
630630
"showline": false,
631+
"ticks": "outside",
631632
"showticklabels": true,
632633
"tickcolor": "rgb(127,127,127)",
633634
"gridcolor": "rgb(255,255,255)"
@@ -637,6 +638,7 @@
637638
"type": "linear",
638639
"showgrid": true,
639640
"showline": false,
641+
"ticks": "outside",
640642
"showticklabels": true,
641643
"tickcolor": "rgb(127,127,127)",
642644
"gridcolor": "rgb(255,255,255)"
62.1 KB

tests/testthat/test-ggplot-errorbar-horizontal.json

+2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
"type": "linear",
8080
"showgrid": true,
8181
"showline": false,
82+
"ticks": "outside",
8283
"showticklabels": true,
8384
"tickcolor": "rgb(127,127,127)",
8485
"gridcolor": "rgb(255,255,255)"
@@ -88,6 +89,7 @@
8889
"type": "category",
8990
"showgrid": true,
9091
"showline": false,
92+
"ticks": "outside",
9193
"showticklabels": true,
9294
"tickcolor": "rgb(127,127,127)",
9395
"gridcolor": "rgb(255,255,255)"
414 Bytes

tests/testthat/test-ggplot-errorbar.json

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"type": "linear",
4747
"showgrid": true,
4848
"showline": false,
49+
"ticks": "outside",
4950
"showticklabels": true,
5051
"tickcolor": "rgb(127,127,127)",
5152
"gridcolor": "rgb(255,255,255)"
@@ -55,6 +56,7 @@
5556
"type": "linear",
5657
"showgrid": true,
5758
"showline": false,
59+
"ticks": "outside",
5860
"showticklabels": true,
5961
"tickcolor": "rgb(127,127,127)",
6062
"gridcolor": "rgb(255,255,255)"
52.6 KB

tests/testthat/test-ggplot-heatmap.json

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"type": "category",
5353
"showgrid": true,
5454
"showline": false,
55+
"ticks": "outside",
5556
"showticklabels": true,
5657
"tickcolor": "rgb(127,127,127)",
5758
"gridcolor": "rgb(255,255,255)"
@@ -61,6 +62,7 @@
6162
"type": "category",
6263
"showgrid": true,
6364
"showline": false,
65+
"ticks": "outside",
6466
"showticklabels": true,
6567
"tickcolor": "rgb(127,127,127)",
6668
"gridcolor": "rgb(255,255,255)"

tests/testthat/test-ggplot-histogram-barmodestack.json

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"type": "category",
2727
"showgrid": true,
2828
"showline": false,
29+
"ticks": "outside",
2930
"showticklabels": true,
3031
"tickcolor": "rgb(127,127,127)",
3132
"gridcolor": "rgb(255,255,255)"
@@ -35,6 +36,7 @@
3536
"type": "linear",
3637
"showgrid": true,
3738
"showline": false,
39+
"ticks": "outside",
3840
"showticklabels": true,
3941
"tickcolor": "rgb(127,127,127)",
4042
"gridcolor": "rgb(255,255,255)"

tests/testthat/test-ggplot-histogram-binwidth.json

+2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"type": "linear",
7676
"showgrid": true,
7777
"showline": false,
78+
"ticks": "outside",
7879
"showticklabels": true,
7980
"tickcolor": "rgb(127,127,127)",
8081
"gridcolor": "rgb(255,255,255)"
@@ -84,6 +85,7 @@
8485
"type": "linear",
8586
"showgrid": true,
8687
"showline": false,
88+
"ticks": "outside",
8789
"showticklabels": true,
8890
"tickcolor": "rgb(127,127,127)",
8991
"gridcolor": "rgb(255,255,255)"

0 commit comments

Comments
 (0)