Help with legend

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

Help with legend

Rik-4
Could someone try the following in Matlab and send me the resulting image? 
I'm trying to test whether the automatic positioning of the legend box
takes in to account the axes ticks.

--- Start Code ---
clf;
plot (rand (3,3));
set (gca, 'xtick', 1:0.25:3, 'ytick', 0:0.1:1);
set (gca, 'ticklength', [0.03 .05]);
hl = legend ();
print ('legtst.png', '-dpng');
--- End Code ---

Thanks,
Rik

Reply | Threaded
Open this post in threaded view
|

Re: Help with legend

nrjank
n Fri, Dec 14, 2018 at 4:50 PM Rik <[hidden email]> wrote:

>
> Could someone try the following in Matlab and send me the resulting image?
> I'm trying to test whether the automatic positioning of the legend box
> takes in to account the axes ticks.
>
> --- Start Code ---
> clf;
> plot (rand (3,3));
> set (gca, 'xtick', 1:0.25:3, 'ytick', 0:0.1:1);
> set (gca, 'ticklength', [0.03 .05]);
> hl = legend ();
> print ('legtst.png', '-dpng');
> --- End Code ---
>
> Thanks,
> Rik
>
attached.

Matlab2018b.png (20K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Help with legend

bpabbott
Administrator
In reply to this post by Rik-4
> On Dec 15, 2018, at 6:50 AM, Rik <[hidden email]> wrote:
>
> Could someone try the following in Matlab and send me the resulting image?
> I'm trying to test whether the automatic positioning of the legend box
> takes in to account the axes ticks.
>
> --- Start Code ---
> clf;
> plot (rand (3,3));
> set (gca, 'xtick', 1:0.25:3, 'ytick', 0:0.1:1);
> set (gca, 'ticklength', [0.03 .05]);
> hl = legend ();
> print ('legtst.png', '-dpng');
> --- End Code ---
>
> Thanks,
> Rik

Rik,

For auto-placement you should set location to ‘Best’. If no location is specified, it defaults to ’NorthEast”

Ben


Reply | Threaded
Open this post in threaded view
|

Re: Help with legend

Rik-4
On 12/14/2018 02:38 PM, Ben Abbott wrote:

>> On Dec 15, 2018, at 6:50 AM, Rik <[hidden email]> wrote:
>>
>> Could someone try the following in Matlab and send me the resulting image?
>> I'm trying to test whether the automatic positioning of the legend box
>> takes in to account the axes ticks.
>>
>> --- Start Code ---
>> clf;
>> plot (rand (3,3));
>> set (gca, 'xtick', 1:0.25:3, 'ytick', 0:0.1:1);
>> set (gca, 'ticklength', [0.03 .05]);
>> hl = legend ();
>> print ('legtst.png', '-dpng');
>> --- End Code ---
>>
>> Thanks,
>> Rik
> Rik,
>
> For auto-placement you should set location to ‘Best’. If no location is specified, it defaults to ’NorthEast”
>
> Ben

My understanding was that "Best" works to eliminate overlaps between data
in the plots and the legend box.

I was interested in whether, given the location of "NorthEast", it would
try to avoid objects that are associated with the axes like the tick marks.

--Rik


Reply | Threaded
Open this post in threaded view
|

Re: Help with legend

bpabbott
Administrator
> On Dec 15, 2018, at 08:02, Rik <[hidden email]> wrote:
>
> On 12/14/2018 02:38 PM, Ben Abbott wrote:
>>> On Dec 15, 2018, at 6:50 AM, Rik <[hidden email]> wrote:
>>>
>>> Could someone try the following in Matlab and send me the resulting image?
>>> I'm trying to test whether the automatic positioning of the legend box
>>> takes in to account the axes ticks.
>>>
>>> --- Start Code ---
>>> clf;
>>> plot (rand (3,3));
>>> set (gca, 'xtick', 1:0.25:3, 'ytick', 0:0.1:1);
>>> set (gca, 'ticklength', [0.03 .05]);
>>> hl = legend ();
>>> print ('legtst.png', '-dpng');
>>> --- End Code ---
>>>
>>> Thanks,
>>> Rik
>> Rik,
>>
>> For auto-placement you should set location to ‘Best’. If no location is specified, it defaults to ’NorthEast”
>>
>> Ben
>
> My understanding was that "Best" works to eliminate overlaps between data
> in the plots and the legend box.
>
> I was interested in whether, given the location of "NorthEast", it would
> try to avoid objects that are associated with the axes like the tick marks.
>
> --Rik

Ahh, ok I misunderstood

Ben