[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: help with legend
From: |
Valmor de Almeida |
Subject: |
Re: help with legend |
Date: |
Tue, 17 Jan 2012 11:40:36 -0500 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110816 Lightning/1.0b3pre Lanikai/3.1.10 |
On 01/17/2012 10:49 AM, Ben Abbott wrote:
> On Jan 17, 2012, at 10:20 AM, Valmor de Almeida wrote:
>
>> On 01/16/2012 08:24 AM, Ben Abbott wrote:
>>
>>> On Jan 15, 2012, at 9:58 PM, Valmor de Almeida wrote:
>>>
>>>> On 01/15/2012 08:10 PM, Ben Abbott wrote:
>>>>>
>>>>> On Jan 15, 2012, at 2:35 PM, Ben Abbott wrote:
>>>>>
>>>>>> On Jan 15, 2012, at 12:48 PM, Valmor de Almeida wrote:
>>>>>>
>>>>>>> Hello,
>>>>>>>
>>>>>>> I am trying to customize legends on a plotyy axes/lines but I am not
>>>>>>> able to. Here are the commands:
>>>>>>>
>>>>>>> [ax, h1, h2] = plotyy(x1,y1, x2,y2, @plot, @plot);
>>>>>>>
>>>>>>> legend(h1,y1Label,"location",'south',"fontname",'Helvetica');
>>>>>>>
>>>>>>> legend(h2,y2Label,"location",'northeast',"fontname",'Helvetica');
>>>>>>>
>>>>>>> Only the first legend shows up and the font is Courier which I am unable
>>>>>>> to change. Also the text in the legend precedes the key which I would
>>>>>>> like to invert using 'right' but it does not work either.
>>>>>>>
>>>>>>> I am using octave-3.4.0. Would anyone have an example?
>>>>>>>
>>>>>>> Thanks,
>>>>>>>
>>>>>>> --
>>>>>>> Valmor
>>>>>>>
>>>>>>> PS: In the above command I also tried legend(ax(1),...) and it does not
>>>>>>> make a difference.
>>>>>>
>>>>>> Octave tries to duplicate Matlab's implementation of plotyy and legend.
>>>>>>
>>>>>> x1 = 0:5:10;
>>>>>> x2 = 0:10;
>>>>>> y1 = rand (size (x1));
>>>>>> y2 = rand (size (x2));
>>>>>> [ax, h1, h2] = plotyy (x1, y1, x2, y2, @plot, @plot);
>>>>>> y1Label = "y1";
>>>>>> y2Label = "y2";
>>>>>>
>>>>>> The command below should produce the desired legend (please check, the
>>>>>> implementation may have changed since 3.4.0).
>>>>>>
>>>>>> legend ([h1, h2], {y1Label, y2Label}, "location", "south")
>>>>>>
>>>>>> The commands below should also work, but currently reverse the legend
>>>>>> entries.
>>>>>>
>>>>>> legend ({y1Label, y2Label}, "location", "south")
>>>>>>
>>>>>> legend (y1Label, y2Label, "location", "south");
>>>>>>
>>>>>> I've entered a bug report in the tracker.
>>>>>>
>>>>>> https://savannah.gnu.org/bugs/?35314
>>>>>>
>>>>>> Regarding "Fontsize", the legend function doesn't accept property
>>>>>> names/values as input.
>>>>>>
>>>>>> To change the fontname, the legend command returns the handle to the
>>>>>> legend. You can change its fontname property directly.
>>>>>>
>>>>>> h = legend ([h1, h2], {y1Label, y2Label}, "location", "south")
>>>>>> set (h, "fontname",'Helvetica")
>>>>>>
>>>>>> Ben
>>>>>
>>>>> I've attached a changeset to the bug-tracker that fixes the legend
>>>>> command so that all three versions below work the same.
>>>>>
>>>>> legend ([h1, h2], {y1Label, y2Label}, "location", "south")
>>>>>
>>>>> legend ({y1Label, y2Label}, "location", "south")
>>>>>
>>>>> legend (y1Label, y2Label, "location", "south");
>>>>>
>>>>> The tracker link is below.
>>>>>
>>>>> https://savannah.gnu.org/bugs/index.php?35314
>>>>>
>>>>> Ben
>>>>>
>>>>
>>>> Thanks Ben,
>>>>
>>>> None of the forms work for my version 3.4.0.
>>>>
>>>> error: /usr/share/octave/3.4.0/m/plot/__gnuplot_print__.m at line 170,
>>>> column 5
>>>>
>>>> The handle to set the fontname does not work either. Which version are
>>>> you using? 3.4.3 is the highest I will be able to go unless I compile
>>>> octave myself.
>>>>
>>>> --
>>>> Valmor
>>>
>>>
>>> The error from __gnplot_print__() is something different. That function
>>> only is called by print().
>>>
>>> Running 3.4.0, I checked ...
>>>
>>> x = 0:10;
>>> plotyy (x, sqrt(x), x, x.^2);
>>> h = legend ("root", "squared");
>>> set (h, "fontname", "Courier")
>>> print test.eps
>>> print test.png
>>>
>>> ... I encountered no errors, and obtained the expected results.
>>>
>>> Can you provide a simple example that produces the __gnuplot_print__ error ?
>>>
>>> Ben
>>
>> Hello Ben,
>>
>> Tried your example above and got
>>
>> octave:3> h = legend("root", "squared");
>> error: structure has no member `fontname'
>> error: evaluating argument list element number 1
>> error: called from:
>> error: /usr/share/octave/3.4.0/m/plot/__go_draw_axes__.m at line 2086,
>> column 3
>> error: /usr/share/octave/3.4.0/m/plot/__go_draw_axes__.m at line 1475,
>> column 31
>> error: /usr/share/octave/3.4.0/m/plot/__go_draw_figure__.m at line
>> 119, column 21
>> error: /usr/share/octave/3.4.0/m/plot/__gnuplot_drawnow__.m at line
>> 86, column 5
>
> hmmm ... Please verify you get the same result below.
>
> class (h)
> ans = double
> ishandle (h)
> ans = 1
> get (h, "type")
> ans = axes
>
> Also verify ...
>
> which legend
> `legend' is a function from the file
> /usr/share/octave/3.4.0/m/plot/legend.m
>
> Ben
>
I do.
Thanks,
--
Valmor
- help with legend, Valmor de Almeida, 2012/01/15
- Re: help with legend, Ben Abbott, 2012/01/15
- Re: help with legend, Ben Abbott, 2012/01/15
- Re: help with legend, Valmor de Almeida, 2012/01/15
- Re: help with legend, Ben Abbott, 2012/01/16
- Re: help with legend, Valmor de Almeida, 2012/01/17
- Re: help with legend, Ben Abbott, 2012/01/17
- Re: help with legend,
Valmor de Almeida <=
- Re: help with legend, Ben Abbott, 2012/01/17
- Re: help with legend, Valmor de Almeida, 2012/01/18
- Re: help with legend, Ben Abbott, 2012/01/18