Figure with thick frame

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

Figure with thick frame

Matthias Brennwald-3
I am trying to make a figure that uses a somewhat thicker line for the frame / axes than the lines used for the grid. I tried plotting a rectangle with thick lines to mimic the figure frame. This almost works perfectly, but the lower right corner does not come out well. The lines don't meet nicely (see attachment).

Here's an example to illustrate the problem:

plot (rand(1,5),'-o' , 'Linewidth',2); % plot some data
grid on % show grid lines (thin)
r = axis(); % find the coordinates of the figure frame
rectangle ( 'Position',[r(1) r(3) r(2)-r(1) r(4)-r(3)] , 'Linewidth',5 ) % plot the figure frame using thick lines
print ('test.png') % save to file

Any ideas how to make this work?





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

Re: Figure with thick frame

Pantxo
Matthias Brennwald-3 wrote

> I am trying to make a figure that uses a somewhat thicker line for the
> frame / axes than the lines used for the grid. I tried plotting a
> rectangle with thick lines to mimic the figure frame. This almost works
> perfectly, but the lower right corner does not come out well. The lines
> don't meet nicely (see attachment).
>
> Here's an example to illustrate the problem:
>
> plot (rand(1,5),'-o' , 'Linewidth',2); % plot some data
> grid on % show grid lines (thin)
> r = axis(); % find the coordinates of the figure frame
> rectangle ( 'Position',[r(1) r(3) r(2)-r(1) r(4)-r(3)] , 'Linewidth',5
> ) % plot the figure frame using thick lines
> print ('test.png') % save to file
>
> Any ideas how to make this work?
>
> test.png (29K)
> <http://octave.1599824.n4.nabble.com/attachment/4687658/0/test.png>

Yes, it's a pity that you must use such a trick when you want axes lines
width different from grids line width. I think the following (using a line
with one more segment to have proper line join) instead of a rectangle
should do the job:

...
line ( [r(1) r(2) r(2) r(1) r(1) r(2)] , [r(3) r(3) r(4) r(4) r(3) r(3)],
'Linewidth',5) ## , "linejoin", "miter" )
...

The commented option ("linejoin") will be necessary when you switch to
Octave 4.4 (upcoming release) or corners will be round by default.

Pantxo



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html