Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #13637 > unrolled thread

Issues with Rendering of Graphics[]

Started bytim_brock20@hotmail.com
First post2013-02-28 04:42 +0000
Last post2013-04-03 08:07 +0000
Articles 11 — 6 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Issues with Rendering of Graphics[] tim_brock20@hotmail.com - 2013-02-28 04:42 +0000
    Re: Issues with Rendering of Graphics[] Alan <alan.isaac@gmail.com> - 2013-03-06 03:13 +0000
      Re: Issues with Rendering of Graphics[] tim_brock20@hotmail.com - 2013-03-06 11:04 +0000
    Re: Issues with Rendering of Graphics[] Alexey Popkov <lehin.p@gmail.com> - 2013-03-08 03:47 +0000
    Re: Issues with Rendering of Graphics[] tim_brock20@hotmail.com - 2013-03-12 04:33 +0000
      Re: Issues with Rendering of Graphics[] David Bailey <dave@removedbailey.co.uk> - 2013-03-13 08:18 +0000
        Re: Issues with Rendering of Graphics[] tim_b <tim_brock20@hotmail.com> - 2013-03-14 11:12 +0000
          Re: Issues with Rendering of Graphics[] David Bailey <dave@removedbailey.co.uk> - 2013-03-15 05:46 +0000
      Re: Issues with Rendering of Graphics[] tim_brock20@hotmail.com - 2013-03-16 07:13 +0000
        Re: Issues with Rendering of Graphics[] debguy <johnandsara2@cox.net> - 2013-04-01 04:56 +0000
      Re: Issues with Rendering of Graphics[] tim_b <tim_brock20@hotmail.com> - 2013-04-03 08:07 +0000

#13637 — Issues with Rendering of Graphics[]

Fromtim_brock20@hotmail.com
Date2013-02-28 04:42 +0000
SubjectIssues with Rendering of Graphics[]
Message-ID<kgmn7q$8gn$1@smc.vnet.net>
Hi

I've been trying to design a bar chart from scratch using primitives. I've come across a bit of an odd issue when I try to add horizontal lines across vertical bars as an alternative to grid lines.

The list rectangles looks like the following:
{Rectangle[{0.1, 0}, {0.9, 35}], Rectangle[{1.1, 0}, {1.9, 89}],
 Rectangle[{2.1, 0}, {2.9, 9}], Rectangle[{3.1, 0}, {3.9, 57}],
 Rectangle[{4.1, 0}, {4.9, 88}], Rectangle[{5.1, 0}, {5.9, 51}],
 Rectangle[{6.1, 0}, {6.9, 52}], Rectangle[{7.1, 0}, {7.9, 62}],
 Rectangle[{8.1, 0}, {8.9, 78}], Rectangle[{9.1, 0}, {9.9, 50}]}

The list markers20 looks like the following:
{{Line[{{0.1, 20}, {0.9, 20}}]}, {Line[{{1.1, 20}, {1.9, 20}}],
  Line[{{1.1, 40}, {1.9, 40}}], Line[{{1.1, 60}, {1.9, 60}}],
  Line[{{1.1, 80}, {1.9, 80}}]}, {}, {Line[{{3.1, 20}, {3.9, 20}}],
  Line[{{3.1, 40}, {3.9, 40}}]}, {Line[{{4.1, 20}, {4.9, 20}}],
  Line[{{4.1, 40}, {4.9, 40}}], Line[{{4.1, 60}, {4.9, 60}}],
  Line[{{4.1, 80}, {4.9, 80}}]}, {Line[{{5.1, 20}, {5.9, 20}}],
  Line[{{5.1, 40}, {5.9, 40}}]}, {Line[{{6.1, 20}, {6.9, 20}}],
  Line[{{6.1, 40}, {6.9, 40}}]}, {Line[{{7.1, 20}, {7.9, 20}}],
  Line[{{7.1, 40}, {7.9, 40}}],
  Line[{{7.1, 60}, {7.9, 60}}]}, {Line[{{8.1, 20}, {8.9, 20}}],
  Line[{{8.1, 40}, {8.9, 40}}],
  Line[{{8.1, 60}, {8.9, 60}}]}, {Line[{{9.1, 20}, {9.9, 20}}],
  Line[{{9.1, 40}, {9.9, 40}}]}}

And I use the following command to draw:

 Graphics[
 {
  RGBColor[136/255, 189/255, 204/255],
  rectangles,
  GrayLevel[0.25],
  CapForm["Butt"],
  markers20
  },
 PlotRange -> {{-1, 11}, {-10, 100}}, AspectRatio -> 1,
 ImageSize -> 600
 ]

The problem I'm having is that the horizontal markers which should stretch exactly from the left of a bar to the right of a bar are rendered as starting slightly inside of the bar on the left-hand side and go slightly outside on the right-hand side. I've tried changing the CapForm for the lines but that doesn't fix the problem.
Oddly, if I wrap the above inside of Image[] the problem goes away but in eneral I don't want to do this.
I'm using Mathematica 9.0.1.

[toc] | [next] | [standalone]


#13724

FromAlan <alan.isaac@gmail.com>
Date2013-03-06 03:13 +0000
Message-ID<kh6c8p$b22$1@smc.vnet.net>
In reply to#13637
Just making sure you are aware of BarChart:
http://reference.wolfram.com/mathematica/ref/BarChart.html 

Alan Isaac

[toc] | [prev] | [next] | [standalone]


#13738

Fromtim_brock20@hotmail.com
Date2013-03-06 11:04 +0000
Message-ID<kh77sf$q94$1@smc.vnet.net>
In reply to#13724
On Wednesday, March 6, 2013 3:13:29 AM UTC, Alan wrote:
> Just making sure you are aware of BarChart:
> 
> http://reference.wolfram.com/mathematica/ref/BarChart.html 
> 
> 
> 
> Alan Isaac

Hi Alan,

Yes thanks. I was experimenting/trying to make something completely from scratch to learn how things work.

Thanks,

Tim

[toc] | [prev] | [next] | [standalone]


#13754

FromAlexey Popkov <lehin.p@gmail.com>
Date2013-03-08 03:47 +0000
Message-ID<khbn0r$cdn$1@smc.vnet.net>
In reply to#13637
Hi!

Try to swith off antialiasing:

Style[Graphics[{RGBColor[136/255, 189/255, 204/255], rectangles,
   GrayLevel[0.25], CapForm["Butt"], markers20},
  PlotRange -> {{-1, 11}, {-10, 100}}, AspectRatio -> 1,
  ImageSize -> 600], Antialiasing -> False]

works for me.

HTH,
Alexey


On Thursday, February 28, 2013 8:42:34 AM UTC+4, tim_b...@hotmail.com wrote:
> Hi
>
>
>
> I've been trying to design a bar chart from scratch using primitives. I've come across a bit of an odd issue when I try to add horizontal lines across vertical bars as an alternative to grid lines.
>
>
>
> The list rectangles looks like the following:
>
> {Rectangle[{0.1, 0}, {0.9, 35}], Rectangle[{1.1, 0}, {1.9, 89}],
>
>  Rectangle[{2.1, 0}, {2.9, 9}], Rectangle[{3.1, 0}, {3.9, 57}],
>
>  Rectangle[{4.1, 0}, {4.9, 88}], Rectangle[{5.1, 0}, {5.9, 51}],
>
>  Rectangle[{6.1, 0}, {6.9, 52}], Rectangle[{7.1, 0}, {7.9, 62}],
>
>  Rectangle[{8.1, 0}, {8.9, 78}], Rectangle[{9.1, 0}, {9.9, 50}]}
>
>
>
> The list markers20 looks like the following:
>
> {{Line[{{0.1, 20}, {0.9, 20}}]}, {Line[{{1.1, 20}, {1.9, 20}}],
>
>   Line[{{1.1, 40}, {1.9, 40}}], Line[{{1.1, 60}, {1.9, 60}}],
>
>   Line[{{1.1, 80}, {1.9, 80}}]}, {}, {Line[{{3.1, 20}, {3.9, 20}}],
>
>   Line[{{3.1, 40}, {3.9, 40}}]}, {Line[{{4.1, 20}, {4.9, 20}}],
>
>   Line[{{4.1, 40}, {4.9, 40}}], Line[{{4.1, 60}, {4.9, 60}}],
>
>   Line[{{4.1, 80}, {4.9, 80}}]}, {Line[{{5.1, 20}, {5.9, 20}}],
>
>   Line[{{5.1, 40}, {5.9, 40}}]}, {Line[{{6.1, 20}, {6.9, 20}}],
>
>   Line[{{6.1, 40}, {6.9, 40}}]}, {Line[{{7.1, 20}, {7.9, 20}}],
>
>   Line[{{7.1, 40}, {7.9, 40}}],
>
>   Line[{{7.1, 60}, {7.9, 60}}]}, {Line[{{8.1, 20}, {8.9, 20}}],
>
>   Line[{{8.1, 40}, {8.9, 40}}],
>
>   Line[{{8.1, 60}, {8.9, 60}}]}, {Line[{{9.1, 20}, {9.9, 20}}],
>
>   Line[{{9.1, 40}, {9.9, 40}}]}}
>
>
>
> And I use the following command to draw:
>
>
>
>  Graphics[
>
>  {
>
>   RGBColor[136/255, 189/255, 204/255],
>
>   rectangles,
>
>   GrayLevel[0.25],
>
>   CapForm["Butt"],
>
>   markers20
>
>   },
>
>  PlotRange -> {{-1, 11}, {-10, 100}}, AspectRatio -> 1,
>
>  ImageSize -> 600
>
>  ]
>
>
>
> The problem I'm having is that the horizontal markers which should stretch exactly from the left of a bar to the right of a bar are rendered as starting slightly inside of the bar on the left-hand side and go slightly outside on the right-hand side. I've tried changing the CapForm for the lines but that doesn't fix the problem.
>
> Oddly, if I wrap the above inside of Image[] the problem goes away but in general I don't want to do this.
>
> I'm using Mathematica 9.0.1.

[toc] | [prev] | [next] | [standalone]


#13813

Fromtim_brock20@hotmail.com
Date2013-03-12 04:33 +0000
Message-ID<khmb7g$nda$1@smc.vnet.net>
In reply to#13637
Thanks. I tried this but it didn't solve the problem for me.

On Thursday, February 28, 2013 4:42:34 AM UTC, tim_b...@hotmail.com wrote:
> Hi
>
>
>
> I've been trying to design a bar chart from scratch using primitives. I've come across a bit of an odd issue when I try to add horizontal lines across vertical bars as an alternative to grid lines.
>
>
>
> The list rectangles looks like the following:
>
> {Rectangle[{0.1, 0}, {0.9, 35}], Rectangle[{1.1, 0}, {1.9, 89}],
>
>  Rectangle[{2.1, 0}, {2.9, 9}], Rectangle[{3.1, 0}, {3.9, 57}],
>
>  Rectangle[{4.1, 0}, {4.9, 88}], Rectangle[{5.1, 0}, {5.9, 51}],
>
>  Rectangle[{6.1, 0}, {6.9, 52}], Rectangle[{7.1, 0}, {7.9, 62}],
>
>  Rectangle[{8.1, 0}, {8.9, 78}], Rectangle[{9.1, 0}, {9.9, 50}]}
>
>
>
> The list markers20 looks like the following:
>
> {{Line[{{0.1, 20}, {0.9, 20}}]}, {Line[{{1.1, 20}, {1.9, 20}}],
>
>   Line[{{1.1, 40}, {1.9, 40}}], Line[{{1.1, 60}, {1.9, 60}}],
>
>   Line[{{1.1, 80}, {1.9, 80}}]}, {}, {Line[{{3.1, 20}, {3.9, 20}}],
>
>   Line[{{3.1, 40}, {3.9, 40}}]}, {Line[{{4.1, 20}, {4.9, 20}}],
>
>   Line[{{4.1, 40}, {4.9, 40}}], Line[{{4.1, 60}, {4.9, 60}}],
>
>   Line[{{4.1, 80}, {4.9, 80}}]}, {Line[{{5.1, 20}, {5.9, 20}}],
>
>   Line[{{5.1, 40}, {5.9, 40}}]}, {Line[{{6.1, 20}, {6.9, 20}}],
>
>   Line[{{6.1, 40}, {6.9, 40}}]}, {Line[{{7.1, 20}, {7.9, 20}}],
>
>   Line[{{7.1, 40}, {7.9, 40}}],
>
>   Line[{{7.1, 60}, {7.9, 60}}]}, {Line[{{8.1, 20}, {8.9, 20}}],
>
>   Line[{{8.1, 40}, {8.9, 40}}],
>
>   Line[{{8.1, 60}, {8.9, 60}}]}, {Line[{{9.1, 20}, {9.9, 20}}],
>
>   Line[{{9.1, 40}, {9.9, 40}}]}}
>
>
>
> And I use the following command to draw:
>
>
>
>  Graphics[
>
>  {
>
>   RGBColor[136/255, 189/255, 204/255],
>
>   rectangles,
>
>   GrayLevel[0.25],
>
>   CapForm["Butt"],
>
>   markers20
>
>   },
>
>  PlotRange -> {{-1, 11}, {-10, 100}}, AspectRatio -> 1,
>
>  ImageSize -> 600
>
>  ]
>
>
>
> The problem I'm having is that the horizontal markers which should stretch exactly from the left of a bar to the right of a bar are rendered as starting slightly inside of the bar on the left-hand side and go slightly outside on the right-hand side. I've tried changing the CapForm for the lines but that doesn't fix the problem.
>
> Oddly, if I wrap the above inside of Image[] the problem goes away but ineneral I don't want to do this.
>
> I'm using Mathematica 9.0.1.

[toc] | [prev] | [next] | [standalone]


#13822

FromDavid Bailey <dave@removedbailey.co.uk>
Date2013-03-13 08:18 +0000
Message-ID<khpcpc$mef$1@smc.vnet.net>
In reply to#13813
On 12/03/2013 04:33, tim_brock20@hotmail.com wrote:
> Thanks. I tried this but it didn't solve the problem for me.
>

I tried this under 8.0.4 (in case it was a bug with 9), but the same 
thing happens. It almost looks as though rectangles are drawn with space 
left for an edge. This cleaned it up for me:

Graphics[{{EdgeForm[{Thick, RGBColor[136/255, 189/255, 204/255]}],
    RGBColor[136/255, 189/255, 204/255], rectangles, GrayLevel[0.25],
    markers20}, PlotRange -> {{-1, 11}, {-10, 100}}}, AspectRatio -> 1,
   ImageSize -> 600]

Note I have made the edges the same colour as the bulk of the rectangles.

David Bailey
http://www.dbaileyconsultancy.co.uk

[toc] | [prev] | [next] | [standalone]


#13840

Fromtim_b <tim_brock20@hotmail.com>
Date2013-03-14 11:12 +0000
Message-ID<khsbbk$36b$1@smc.vnet.net>
In reply to#13822
Thanks.

This seems to stop the horizontal lines poking out the edge on the right. But now I have a gap on the inside on the left instead. Curious.



On Wednesday, March 13, 2013 8:18:52 AM UTC, David Bailey wrote:
> 
> 
> > Thanks. I tried this but it didn't solve the problem for me.
> 
> >
> 
> 
> 
> I tried this under 8.0.4 (in case it was a bug with 9), but the same 
> 
> thing happens. It almost looks as though rectangles are drawn with space 
> 
> left for an edge. This cleaned it up for me:
> 
> 
> 
> Graphics[{{EdgeForm[{Thick, RGBColor[136/255, 189/255, 204/255]}],
> 
>     RGBColor[136/255, 189/255, 204/255], rectangles, GrayLevel[0.25],
> 
>     markers20}, PlotRange -> {{-1, 11}, {-10, 100}}}, AspectRatio -> 1,
> 
>    ImageSize -> 600]
> 
> 
> 
> Note I have made the edges the same colour as the bulk of the rectangles.
> 
> 
> 
> David Bailey
> 
> http://www.dbaileyconsultancy.co.uk

[toc] | [prev] | [next] | [standalone]


#13849

FromDavid Bailey <dave@removedbailey.co.uk>
Date2013-03-15 05:46 +0000
Message-ID<khuck3$93$1@smc.vnet.net>
In reply to#13840
On 14/03/2013 11:12, tim_b wrote:
> Thanks.
>
> This seems to stop the horizontal lines poking out the edge on the right. But now I have a gap on the inside on the left instead. Curious.
>
>


Switching to a thin edge seems to fix that too!

Graphics[{{EdgeForm[{Thin, RGBColor[136/255, 189/255, 204/255]}],
    RGBColor[136/255, 189/255, 204/255], rectangles, GrayLevel[0.25],
    markers20}, PlotRange -> {{-1, 11}, {-10, 100}}}, AspectRatio -> 1,
   ImageSize -> 600]

I also used:

eps = 1/10;

and used that rather than 0.1 in the definition of the various 
structures - just to avoid any possible floating point issues.


It is strange that something like this is so hard. I reckon thick edges 
must extend outside the area of the rectangles.

It would be nice if someone from WRI commented on this - have you tried 
sending it to support?

David Bailey
http://www.dbaileyconsultancy.co.uk

[toc] | [prev] | [next] | [standalone]


#13860

Fromtim_brock20@hotmail.com
Date2013-03-16 07:13 +0000
Message-ID<ki163h$5uk$1@smc.vnet.net>
In reply to#13813
It's gone to the lines poking out the right edge again for me, although the problem seems to get less and less significant as I go from the left most bar to the right most.

I've only got a trial version at the minute and when I asked about support I was told to check here because they don't offer proper support until you 
are licensed. I can understand this in a way but the fact that I've come across a problem I can't solve makes me less inclined to spend money on their product.

Thanks again for taking the time,

Tim


> On 14/03/2013 11:12, tim_b wrote:
>
> > Thanks.
>
> >
>
> > This seems to stop the horizontal lines poking out the edge on the right. But now I have a gap on the inside on the left instead. Curious.
>
> >
>
> >
>
>
>
>
>
> Switching to a thin edge seems to fix that too!
>
>
>
> Graphics[{{EdgeForm[{Thin, RGBColor[136/255, 189/255, 204/255]}],
>
>     RGBColor[136/255, 189/255, 204/255], rectangles, GrayLevel[0.25],
>
>     markers20}, PlotRange -> {{-1, 11}, {-10, 100}}}, AspectRatio -> 1,
>
>    ImageSize -> 600]
>
>
>
> I also used:
>
>
>
> eps = 1/10;
>
>
>
> and used that rather than 0.1 in the definition of the various
>
> structures - just to avoid any possible floating point issues.
>
>
>
>
>
> It is strange that something like this is so hard. I reckon thick edges
>
> must extend outside the area of the rectangles.
>
>
>
> It would be nice if someone from WRI commented on this - have you tried
>
> sending it to support?
>
>
>
> David Bailey
>
> http://www.dbaileyconsultancy.co.uk

[toc] | [prev] | [next] | [standalone]


#13986

Fromdebguy <johnandsara2@cox.net>
Date2013-04-01 04:56 +0000
Message-ID<kjb42b$8iv$1@smc.vnet.net>
In reply to#13860
Hi.  I use a previous version, Mathematica 4.0 and it does the same thing.
It's not "a bug".

Rectangle is a "baked" 2D ~Graphics~ function and can put graphics
inside the fill area and use Scaled and Offset to.  Neat!  But it's
done internal you can't get at / get it to give you a list of drawing
primitives it finally uses. (as opposed to Plot3D where you can get a
list of Poly if you want).

Maybe just shorten your Lines?  Or use the baked feature: fill the
Rect with your lines and that should line up nicely.

You should used filled Polygon unless you want to deal with these
"baked polygon" unknowable boder allowance issues.  Soon as you get it
to work by mending it one way you'll find out some other important
thing Mathematica supports changes it in another way.  You know?

[toc] | [prev] | [next] | [standalone]


#14034

Fromtim_b <tim_brock20@hotmail.com>
Date2013-04-03 08:07 +0000
Message-ID<kjgnvm$pq7$1@smc.vnet.net>
In reply to#13813
Thanks.
My trial has expired so I'm not in a position at the minute to experiment any more. If this position changes at some point I will have another go.

Cheers
Tim 



On Monday, April 1, 2013 5:56:43 AM UTC+1, debguy wrote:
> Hi.  I use a previous version, Mathematica 4.0 and it does the same thing.
> 
> It's not "a bug".
> 
> 
> 
> Rectangle is a "baked" 2D ~Graphics~ function and can put graphics
> 
> inside the fill area and use Scaled and Offset to.  Neat!  But it's
> 
> done internal you can't get at / get it to give you a list of drawing
> 
> primitives it finally uses. (as opposed to Plot3D where you can get a
> 
> list of Poly if you want).
> 
> 
> 
> Maybe just shorten your Lines?  Or use the baked feature: fill the
> 
> Rect with your lines and that should line up nicely.
> 
> 
> 
> You should used filled Polygon unless you want to deal with these
> 
> "baked polygon" unknowable boder allowance issues.  Soon as you get it
> 
> to work by mending it one way you'll find out some other important
> 
> thing Mathematica supports changes it in another way.  You know?

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web