emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Change both width and height of R plot in SRC block
@ 2022-06-30  8:10 Gerardo Moro
  2022-06-30 12:46 ` William Denton
  2022-06-30 12:51 ` Ihor Radchenko
  0 siblings, 2 replies; 6+ messages in thread
From: Gerardo Moro @ 2022-06-30  8:10 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1210 bytes --]

Hi,

I have been trying for over a year to change the output plot size when
using Orgmode SRC blocks with R. I have tried both using orgmode settings
and R settings.

I have a table from which I take some values.

#+name: cost
#+begin_src R :results output file graphics :file imag/cost.jpg :var
tab=cost
library(ggplot2)

ggplot(tab, aes(x = date, y = cost)) +
geom_line(color="darkgreen") + geom_point() +
scale_x_date(date_breaks = "1 day",
date_labels = "%b %d") +
theme(axis.text.x = element_text(angle = 90)) +
scale_y_continuous(breaks=seq(100,200,1)) +
ylim(100, 200)
#+end_src

The resulting plot (only showing the x axis) is squared, so the resulting X
axis is not legible at all:

#+RESULTS: cost
[image: image.png]

I have spent months to try to figure out how to have a non-square plot
showing in Orgmode, to no avail.

This presses me to stop using Emacs for graphing altogether.

I have head that this has more to do with R than with Emacs, but I have
tried all the R code advice out there.

I also have tried of course the #+attr_org: :width 600px :height:300px, but
it only considers the width, so I end up with another square.

If any of you has a solution,  much appreciated!

Best,
G. Moro

[-- Attachment #1.2: Type: text/html, Size: 1637 bytes --]

[-- Attachment #2: image.png --]
[-- Type: image/png, Size: 88665 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Change both width and height of R plot in SRC block
  2022-06-30  8:10 Change both width and height of R plot in SRC block Gerardo Moro
@ 2022-06-30 12:46 ` William Denton
  2022-06-30 12:51 ` Ihor Radchenko
  1 sibling, 0 replies; 6+ messages in thread
From: William Denton @ 2022-06-30 12:46 UTC (permalink / raw)
  To: Gerardo Moro; +Cc: emacs-orgmode

On 30 June 2022, Gerardo Moro wrote:

> I have been trying for over a year to change the output plot size when
> using Orgmode SRC blocks with R. I have tried both using orgmode settings
> and R settings.
>
> I have a table from which I take some values.
>
> #+name: cost
> #+begin_src R :results output file graphics :file imag/cost.jpg :var tab=cost

You can put height and width attributes for the image into the source block 
header:

#+begin_src R :results output file graphics :file imag/cost.jpg :var tab=cost :width 800 :height 400

(You mention #+attr_org, but there's a bad colon in what you quote.)

If this doesn't work, please give a reproducible example, and we can figure it 
out.  The code you quote doesn't work because we don't have the cost data.


Bill

--
William Denton
https://www.miskatonic.org/
Librarian, artist and licensed private investigator.
Toronto, Canada


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Change both width and height of R plot in SRC block
  2022-06-30  8:10 Change both width and height of R plot in SRC block Gerardo Moro
  2022-06-30 12:46 ` William Denton
@ 2022-06-30 12:51 ` Ihor Radchenko
  2022-06-30 18:30   ` Gerardo Moro
  1 sibling, 1 reply; 6+ messages in thread
From: Ihor Radchenko @ 2022-06-30 12:51 UTC (permalink / raw)
  To: Gerardo Moro; +Cc: emacs-orgmode

Gerardo Moro <gerardomoro37@gmail.com> writes:

> I have been trying for over a year to change the output plot size when
> using Orgmode SRC blocks with R. I have tried both using orgmode settings
> and R settings.

Have you tried :with and :height header arguments?

> I have a table from which I take some values.

It would be more helpful if you provided a completely reproducible
example that others can also run.

Best,
Ihor


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Change both width and height of R plot in SRC block
  2022-06-30 12:51 ` Ihor Radchenko
@ 2022-06-30 18:30   ` Gerardo Moro
  2022-06-30 18:51     ` Thomas S. Dye
  0 siblings, 1 reply; 6+ messages in thread
From: Gerardo Moro @ 2022-06-30 18:30 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 719 bytes --]

Oh my god, this works! I honestly tried everything but...
Apologies.
Where can I read more about the possible options at header in source blocks?
Thanks!

El jue, 30 jun 2022 a las 15:50, Ihor Radchenko (<yantar92@gmail.com>)
escribió:

> Gerardo Moro <gerardomoro37@gmail.com> writes:
>
> > I have been trying for over a year to change the output plot size when
> > using Orgmode SRC blocks with R. I have tried both using orgmode settings
> > and R settings.
>
> Have you tried :with and :height header arguments?
>
> > I have a table from which I take some values.
>
> It would be more helpful if you provided a completely reproducible
> example that others can also run.
>
> Best,
> Ihor
>

[-- Attachment #2: Type: text/html, Size: 1132 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Change both width and height of R plot in SRC block
  2022-06-30 18:30   ` Gerardo Moro
@ 2022-06-30 18:51     ` Thomas S. Dye
  2022-07-01 11:01       ` Jeremie Juste
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas S. Dye @ 2022-06-30 18:51 UTC (permalink / raw)
  To: Gerardo Moro; +Cc: Ihor Radchenko, emacs-orgmode

Aloha Gerardo,

Please see this Worg page: 
https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-R.html 

All the best,
Tom

Gerardo Moro <gerardomoro37@gmail.com> writes:

> Oh my god, this works! I honestly tried everything but...
> Apologies.
> Where can I read more about the possible options at header in 
> source blocks?
> Thanks!
>
> El jue, 30 jun 2022 a las 15:50, Ihor Radchenko 
> (<yantar92@gmail.com>)
> escribió:
>
>> Gerardo Moro <gerardomoro37@gmail.com> writes:
>>
>> > I have been trying for over a year to change the output plot 
>> > size when
>> > using Orgmode SRC blocks with R. I have tried both using 
>> > orgmode settings
>> > and R settings.
>>
>> Have you tried :with and :height header arguments?
>>
>> > I have a table from which I take some values.
>>
>> It would be more helpful if you provided a completely 
>> reproducible
>> example that others can also run.
>>
>> Best,
>> Ihor
>>


-- 
Thomas S. Dye
https://tsdye.online/tsdye


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Change both width and height of R plot in SRC block
  2022-06-30 18:51     ` Thomas S. Dye
@ 2022-07-01 11:01       ` Jeremie Juste
  0 siblings, 0 replies; 6+ messages in thread
From: Jeremie Juste @ 2022-07-01 11:01 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: Gerardo Moro, Ihor Radchenko, emacs-orgmode


Hello Gerado,

Thanks for your email. I'm glad you reached out to the community.

>>> Gerardo Moro <gerardomoro37@gmail.com> writes:
>>>
>>> > I have been trying for over a year to change the output plot  >
>>> size when
>>> > using Orgmode SRC blocks with R. I have tried both using  >
>>> orgmode settings
>>> > and R settings.

I feel your pain and frustration here. In the future, please reach out to the
mailing list sooner. We think (together) therefore we R (org-mode users) ;-).

> Gerardo Moro <gerardomoro37@gmail.com> writes:
>
>> Oh my god, this works! I honestly tried everything but...
>> Apologies.

No need to apologise, but I hope reaching out to
the mailing list will be in your definition of everything :-).


Many thanks to Ihor and Thomas for your reactivity.

Best regards,
Jeremie


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-07-01 11:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-30  8:10 Change both width and height of R plot in SRC block Gerardo Moro
2022-06-30 12:46 ` William Denton
2022-06-30 12:51 ` Ihor Radchenko
2022-06-30 18:30   ` Gerardo Moro
2022-06-30 18:51     ` Thomas S. Dye
2022-07-01 11:01       ` Jeremie Juste

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).