Controlling Axes, etc. for Simple 2D Plots

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Controlling Axes, etc. for Simple 2D Plots

BradD
I'm having a lot of trouble understanding how to control the size of plots, axes positions, etc. For example, a current script of mine is resulting in the y-axis label being pushed too far to the right, so it's overlapping the numerical values on the y-axis. Is there a clear example of how to use papersize, paperposition, defaultaxesposition, etc.?

Brad Davis, Ph.D., S.E.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Controlling Axes, etc. for Simple 2D Plots

BradD
Dear Group,

Some help with this would be greatly appreciated. The following is the relevant code for my plots. Attached is the result. The bottom parts of the "q" and "y" in the x-axis label are chopped off. What do I need to do to stop this from happening?

Also, if anybody has a group of examples for plotting, sharing would be greatly appreciated.

TextSize = 10;
axes('FontSize',TextSize);
h = figure;
set(h,'PaperSize',[4 3.5]);
set(h,'PaperPosition',[0.1,0.4,4,3]);
set(gca,'fontname','Times');      
hold on;
box on;
grid on;  
plot(f(:,1),ModeShape(:,1),'r','linewidth',1);
plot(f(:,2),ModeShape(:,2),'g--','linewidth',1);
plot(f(:,3),ModeShape(:,3),'b-.','linewidth',1);
xlabel('Frequency (Hz)','fontsize',TextSize);
ylabel('Mode Shape Value','fontsize',TextSize);

Brad Davis, Ph.D., S.E.
[hidden email]

On Sat, Sep 7, 2019 at 2:12 PM Brad Davis <[hidden email]> wrote:
I'm having a lot of trouble understanding how to control the size of plots, axes positions, etc. For example, a current script of mine is resulting in the y-axis label being pushed too far to the right, so it's overlapping the numerical values on the y-axis. Is there a clear example of how to use papersize, paperposition, defaultaxesposition, etc.?

Brad Davis, Ph.D., S.E.
[hidden email]



S1HDat2B.pdf (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Controlling Axes, etc. for Simple 2D Plots

mmuetzel
In reply to this post by BradD
On Mon, 9 Sep 2019 06:15:54 -0400 Brad Davis wrote:

> Dear Group,
>
> Some help with this would be greatly appreciated. The following is the
> relevant code for my plots. Attached is the result. The bottom parts of the
> "q" and "y" in the x-axis label are chopped off. What do I need to do to
> stop this from happening?
>
> Also, if anybody has a group of examples for plotting, sharing would be
> greatly appreciated.
>
> TextSize = 10;
> axes('FontSize',TextSize);
> h = figure;
> set(h,'PaperSize',[4 3.5]);
> set(h,'PaperPosition',[0.1,0.4,4,3]);
> set(gca,'fontname','Times');
> hold on;
> box on;
> grid on;
> plot(f(:,1),ModeShape(:,1),'r','linewidth',1);
> plot(f(:,2),ModeShape(:,2),'g--','linewidth',1);
> plot(f(:,3),ModeShape(:,3),'b-.','linewidth',1);
> xlabel('Frequency (Hz)','fontsize',TextSize);
> ylabel('Mode Shape Value','fontsize',TextSize);
>
> Brad Davis, Ph.D., S.E.
> [hidden email]
>
> On Sat, Sep 7, 2019 at 2:12 PM Brad Davis <[hidden email]> wrote:
>
> > I'm having a lot of trouble understanding how to control the size of
> > plots, axes positions, etc. For example, a current script of mine is
> > resulting in the y-axis label being pushed too far to the right, so it's
> > overlapping the numerical values on the y-axis. Is there a clear example of
> > how to use papersize, paperposition, defaultaxesposition, etc.?
> >
> > Brad Davis, Ph.D., S.E.
> > [hidden email]

Brad,

I cannot reproduce your exampls because I don't have the data for the variables "f"
and "ModeShape".
But here some general questions:
Which graphics toolkit are you using? Have you tried with other graphics toolkits?
What happens if you execute one of the following lines before your code?
close('all'); graphics_toolkit('qt');
close('all'); graphics_toolkit('fltk');
close('all'); graphics_toolkit('gnuplot');

Do you see the issues on screen or when plotting to a file?

Markus



Reply | Threaded
Open this post in threaded view
|

Re: Controlling Axes, etc. for Simple 2D Plots

BradD
Markus and the group,

Thanks for the reply. I attached a modified version of the program that should work on your machines. The x and y values are fake.

My goal is to print the figure to pdf, so the resulting pdf is attached. In the x-axis label, the bottom parts of the q, y, (, and ) are chopped off. What would fix this?

Thanks for any help.

Brad Davis, Ph.D., S.E.
[hidden email]


On Mon, Sep 9, 2019 at 10:27 AM "Markus Mützel" <[hidden email]> wrote:
On Mon, 9 Sep 2019 06:15:54 -0400 Brad Davis wrote:
> Dear Group,
>
> Some help with this would be greatly appreciated. The following is the
> relevant code for my plots. Attached is the result. The bottom parts of the
> "q" and "y" in the x-axis label are chopped off. What do I need to do to
> stop this from happening?
>
> Also, if anybody has a group of examples for plotting, sharing would be
> greatly appreciated.
>
> TextSize = 10;
> axes('FontSize',TextSize);
> h = figure;
> set(h,'PaperSize',[4 3.5]);
> set(h,'PaperPosition',[0.1,0.4,4,3]);
> set(gca,'fontname','Times');
> hold on;
> box on;
> grid on;
> plot(f(:,1),ModeShape(:,1),'r','linewidth',1);
> plot(f(:,2),ModeShape(:,2),'g--','linewidth',1);
> plot(f(:,3),ModeShape(:,3),'b-.','linewidth',1);
> xlabel('Frequency (Hz)','fontsize',TextSize);
> ylabel('Mode Shape Value','fontsize',TextSize);
>
> Brad Davis, Ph.D., S.E.
> [hidden email]
>
> On Sat, Sep 7, 2019 at 2:12 PM Brad Davis <[hidden email]> wrote:
>
> > I'm having a lot of trouble understanding how to control the size of
> > plots, axes positions, etc. For example, a current script of mine is
> > resulting in the y-axis label being pushed too far to the right, so it's
> > overlapping the numerical values on the y-axis. Is there a clear example of
> > how to use papersize, paperposition, defaultaxesposition, etc.?
> >
> > Brad Davis, Ph.D., S.E.
> > [hidden email]

Brad,

I cannot reproduce your exampls because I don't have the data for the variables "f"
and "ModeShape".
But here some general questions:
Which graphics toolkit are you using? Have you tried with other graphics toolkits?
What happens if you execute one of the following lines before your code?
close('all'); graphics_toolkit('qt');
close('all'); graphics_toolkit('fltk');
close('all'); graphics_toolkit('gnuplot');

Do you see the issues on screen or when plotting to a file?

Markus




Example.m (656 bytes) Download Attachment
Example.pdf (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Controlling Axes, etc. for Simple 2D Plots

Dmitri A. Sergatskov
On Mon, Sep 9, 2019 at 12:01 PM Brad Davis <[hidden email]> wrote:

>
> Markus and the group,
>
> Thanks for the reply. I attached a modified version of the program that should work on your machines. The x and y values are fake.
>
> My goal is to print the figure to pdf, so the resulting pdf is attached. In the x-axis label, the bottom parts of the q, y, (, and ) are chopped off. What would fix this?
>
> Thanks for any help.
>
> Brad Davis, Ph.D., S.E.
> [hidden email]
>
What is your octave version?
I do not see this problem with a current dev version. perhaps you hit
the bug that
has been fixed in a later version of octave.

Also in you script you need to call axes()  after figure(); otherwise
it would make
no effect on your plot.

Attached is what I get on my computer (with that axes() fix) and
TextSize set to 20)

Regards,
Dmitri.
--



Example_2.pdf (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Controlling Axes, etc. for Simple 2D Plots

BradD
Dmitri,

I was using version 4.something from 2017. I downloaded and installed the latest and it works perfectly.

Thank you for your help! Have a good day.

Brad Davis, Ph.D., S.E.
[hidden email]



On Mon, Sep 9, 2019 at 1:18 PM Dmitri A. Sergatskov <[hidden email]> wrote:
On Mon, Sep 9, 2019 at 12:01 PM Brad Davis <[hidden email]> wrote:
>
> Markus and the group,
>
> Thanks for the reply. I attached a modified version of the program that should work on your machines. The x and y values are fake.
>
> My goal is to print the figure to pdf, so the resulting pdf is attached. In the x-axis label, the bottom parts of the q, y, (, and ) are chopped off. What would fix this?
>
> Thanks for any help.
>
> Brad Davis, Ph.D., S.E.
> [hidden email]
>

What is your octave version?
I do not see this problem with a current dev version. perhaps you hit
the bug that
has been fixed in a later version of octave.

Also in you script you need to call axes()  after figure(); otherwise
it would make
no effect on your plot.

Attached is what I get on my computer (with that axes() fix) and
TextSize set to 20)

Regards,
Dmitri.
--