Страница 1 из 1

Не отображаются значения меток math_format

Добавлено: 06 май 2020, 16:20
VistaSV30
Добрый день!
Подскажите в чем проблема? Это пример из учебника

Код: Выделить всё

library(MASS) # to access Animals data sets
library(scales) # to access break formatting functions
# x and y axis are transformed and formatted
p2 <- ggplot(Animals, aes(x = body, y = brain)) + geom_point() +
  scale_x_log10(breaks = trans_breaks("log10", function(x) 10^x),
                labels = trans_format("log10", math_format(10^.x))) +
  scale_y_log10(breaks = trans_breaks("log10", function(x) 10^x),
                labels = trans_format("log10", math_format(10^.x))) +
  theme_bw()
# log-log plot without log tick marks
p2
Функция math_format() должна выводить значения меток, но почему-то этого не происходит.
Подскажите, что здесь не так.

Спасибо!

Re: Не отображаются значения меток math_format

Добавлено: 07 май 2020, 08:47
gamm
обновить все пакеты до последних версий + RTFM :mrgreen:

Re: Не отображаются значения меток math_format

Добавлено: 07 май 2020, 10:06
VistaSV30
Вроде бы всё сделал, как Вы советуете, но не помогло

Re: Не отображаются значения меток math_format

Добавлено: 07 май 2020, 13:16
gamm
значит, не все ...

Код: Выделить всё

> library(MASS) # to access Animals data sets
> library(ggplot2)
> library(scales) # to access break formatting functions
> 
> sessionInfo()
other attached packages:
[1] ggplot2_3.3.0 scales_1.1.0  MASS_7.3-51.4

> # x and y axis are transformed and formatted
> p2 <- ggplot(Animals, aes(x = body, y = brain)) + geom_point() +
+   scale_x_log10(breaks = trans_breaks("log10", function(x) 10^x),
+                 labels = trans_format("log10", math_format(10^.x))) +
+   scale_y_log10(breaks = trans_breaks("log10", function(x) 10^x),
+                 labels = trans_format("log10", math_format(10^.x))) +
+   theme_bw()
> # log-log plot without log tick marks
> p2
Буфер обмена-1.png
Буфер обмена-1.png (4.92 КБ) 3280 просмотров

Re: Не отображаются значения меток math_format

Добавлено: 07 май 2020, 13:52
VistaSV30
Всё равно не получается

Код: Выделить всё

>    sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=Russian_Russia.1251  LC_CTYPE=Russian_Russia.1251   
[3] LC_MONETARY=Russian_Russia.1251 LC_NUMERIC=C                   
[5] LC_TIME=Russian_Russia.1251    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] scales_1.0.0  ggplot2_3.3.0 MASS_7.3-51.5
Изображение

Может быть, что-то в настройках надо поменять?

Re: Не отображаются значения меток math_format

Добавлено: 07 май 2020, 13:56
gamm
вы отличить
[1] ggplot2_3.3.0 scales_1.1.0 MASS_7.3-51.4
от
[1] scales_1.0.0 ggplot2_3.3.0 MASS_7.3-51.5
можете?

Re: Не отображаются значения меток math_format

Добавлено: 07 май 2020, 14:07
VistaSV30
Заработало! Спасибо Вам большое!