Mathematica - Specific shading vs global - Mesh or ListPlot?

Click For Summary
SUMMARY

The discussion focuses on shading specific portions of a polygon in Mathematica, particularly when using the Mesh and MeshFunction commands, which apply global shading. The user seeks a method to shade half of a polygon defined by a dotted line. The solution provided involves overlaying another polygon with transparency settings to achieve the desired shading effect. This approach simplifies the task and effectively addresses the user's requirements.

PREREQUISITES
  • Familiarity with Mathematica graphics functions
  • Understanding of polygon definitions in Mathematica
  • Knowledge of opacity settings for graphical elements
  • Experience with the Mesh and MeshFunction commands in Mathematica
NEXT STEPS
  • Explore advanced polygon shading techniques in Mathematica
  • Learn about transparency and opacity settings in Mathematica graphics
  • Investigate the use of Mesh and MeshFunction for complex graphics
  • Study examples of layered graphics in Mathematica for enhanced visual effects
USEFUL FOR

Mathematica users, graphic designers, and data visualizers looking to enhance their skills in polygon shading and graphical representation within the software.

sirole
Messages
2
Reaction score
0
Hi, I am trying to shade two portions of the polygon defined by the dotted line in this code. The Mesh and MeshFunction cmds seem to allot global shading only. What is the best tool to shade, say half of the aforementioned polygon?

Function[{LtMarg, BotMarg, RtMarg, HVal, DVal, rVal},
Graphics[{Mesh -> True, EdgeForm[{Thick, Blue}], FaceForm[Pink],
Polygon[{{0.5, 0}, {1/2,
HVal - 1/2}, {(HVal - DVal + 1)/2, (DVal + HVal - 1)/
2}, {(HVal - DVal + 1)/2, 0}}], EdgeForm[{Thick, Green}],
White, Rectangle[], Blue, Text[0, {0.01, BotMarg}],
Text[0, {LtMarg, 0}], Text[l, {LtMarg, 1}], Text[t, {1, BotMarg}],
Line[{{0, HVal}, {0.5, HVal - 0.5}, {1, HVal}}],
Line[{{0.5, HVal - 0.5}, {0.5, 0}}],
Line[{{0, DVal}, {0.5, DVal - 0.5}, {1, DVal}}],
Text[Vh, {LtMarg, HVal}], Text[Vd, {LtMarg, DVal}],
Text[Vh, {RtMarg, HVal}], Text[Vd, {RtMarg, DVal}], Dotted,
Line[{{(DVal - HVal + 1)/2,
0}, {(DVal - HVal + 1)/2, (DVal + HVal - 1)/2}, {1/2,
HVal - 1/2}, {(HVal - DVal + 1)/2, (DVal + HVal - 1)/
2}, {(HVal - DVal + 1)/2,
0}}]}]][-0.03, -0.03, 1.035, 0.8, 0.65, 0.1]
 
Physics news on Phys.org
I would just put another polygon over it, with some transparency in both the poly and its edges.

Code:
Function[{LtMarg, BotMarg, RtMarg, HVal, DVal, rVal}, 
  Graphics[{Mesh -> True, EdgeForm[{Thick, Blue}], FaceForm[Pink], 
    Polygon[{{0.5, 0}, {1/2, 
       HVal - 1/2}, {(HVal - DVal + 1)/2, (DVal + HVal - 1)/
        2}, {(HVal - DVal + 1)/2, 0}}], EdgeForm[{Thick, Green}], 
    White, Rectangle[], Blue, Text[0, {0.01, BotMarg}], 
    Text[0, {LtMarg, 0}], Text[l, {LtMarg, 1}], Text[t, {1, BotMarg}],
     Line[{{0, HVal}, {0.5, HVal - 0.5}, {1, HVal}}], 
    Line[{{0.5, HVal - 0.5}, {0.5, 0}}], 
    Line[{{0, DVal}, {0.5, DVal - 0.5}, {1, DVal}}], 
    Text[Vh, {LtMarg, HVal}], Text[Vd, {LtMarg, DVal}], 
    Text[Vh, {RtMarg, HVal}], Text[Vd, {RtMarg, DVal}], Dotted, 
    Line[{{(DVal - HVal + 1)/2, 
       0}, {(DVal - HVal + 1)/2, (DVal + HVal - 1)/2}, {1/2, 
       HVal - 1/2}, {(HVal - DVal + 1)/2, (DVal + HVal - 1)/
        2}, {(HVal - DVal + 1)/2, 0}}], Opacity[0.2], 
    EdgeForm[{Transparent}], 
    Polygon[{{(DVal - HVal + 1)/2, 
       0}, {(DVal - HVal + 1)/2, (DVal + HVal - 1)/2}, {1/2, 
       HVal - 1/2}, {1/2, 0}}]}]][-0.03, -0.03, 1.035, 0.8, 0.65, 0.1]
 
Ah! Thank you! That is what I ultimately needed to do, and was trying to make into a more difficult task!