Skip to main content
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link

The question might be considered a duplicate of thisthis question, but for clarity I will show how by adapting the answer given there.

barHatched[gap_, h_, seg_][{{xmin_, xmax_}, {ymin_, ymax_}}, ___] := Module[{width, line, yt, yb, lend}, {yb, yt} = Sort[{ymin, ymax}]; width = xmax - xmin; line = Table[{{xmin, i}, {xmax, i + width}}, {i, yb, yt - width, h/seg}]; lend = line[[-1, 1, 2]]; line = { Line[line], Line[Table[{{xmin + i, yb}, {xmax, yb + width - i}}, {i, h/seg, width, h/seg}]], Line[Table[{{xmin, lend + i}, {xmax - (lend + width - yt) - i, yt}}, {i, h/seg, width + h/seg, h/seg}]] }; {{Opacity[.2], EdgeForm[], Rectangle[{xmin, ymin}, {xmax + gap, ymax}]}, {CapForm["Butt"], line}, {FaceForm[], Rectangle[{xmin, ymin}, {xmax, ymax}]}} ] barSolid[{{xmin_, xmax_}, {ymin_, ymax_}}, ___] := Rectangle[{xmin, ymin}, {xmax, ymax}] mixedBar[args : {{xmin_, xmax_}, {ymin_, ymax_}}, ___] := If[xmax < 3, barHatched[0, 5, 35][args], barSolid[args]] BarChart[ Transpose[{ {2, -1, 1.5, -3, 3, 2.5}, {2, -1, 1.5, -3, 3, 2.5} }], ChartElementFunction -> { mixedBar, barSolid } ] 

Mathematica graphics

The idea is to build custom CharElementFunctions for the bar appearances. To have variation with a set we need to make a ChartElementFunction which depends on the position of the bar. This is what the mixedBar function is for.

The question might be considered a duplicate of this question, but for clarity I will show how by adapting the answer given there.

barHatched[gap_, h_, seg_][{{xmin_, xmax_}, {ymin_, ymax_}}, ___] := Module[{width, line, yt, yb, lend}, {yb, yt} = Sort[{ymin, ymax}]; width = xmax - xmin; line = Table[{{xmin, i}, {xmax, i + width}}, {i, yb, yt - width, h/seg}]; lend = line[[-1, 1, 2]]; line = { Line[line], Line[Table[{{xmin + i, yb}, {xmax, yb + width - i}}, {i, h/seg, width, h/seg}]], Line[Table[{{xmin, lend + i}, {xmax - (lend + width - yt) - i, yt}}, {i, h/seg, width + h/seg, h/seg}]] }; {{Opacity[.2], EdgeForm[], Rectangle[{xmin, ymin}, {xmax + gap, ymax}]}, {CapForm["Butt"], line}, {FaceForm[], Rectangle[{xmin, ymin}, {xmax, ymax}]}} ] barSolid[{{xmin_, xmax_}, {ymin_, ymax_}}, ___] := Rectangle[{xmin, ymin}, {xmax, ymax}] mixedBar[args : {{xmin_, xmax_}, {ymin_, ymax_}}, ___] := If[xmax < 3, barHatched[0, 5, 35][args], barSolid[args]] BarChart[ Transpose[{ {2, -1, 1.5, -3, 3, 2.5}, {2, -1, 1.5, -3, 3, 2.5} }], ChartElementFunction -> { mixedBar, barSolid } ] 

Mathematica graphics

The idea is to build custom CharElementFunctions for the bar appearances. To have variation with a set we need to make a ChartElementFunction which depends on the position of the bar. This is what the mixedBar function is for.

The question might be considered a duplicate of this question, but for clarity I will show how by adapting the answer given there.

barHatched[gap_, h_, seg_][{{xmin_, xmax_}, {ymin_, ymax_}}, ___] := Module[{width, line, yt, yb, lend}, {yb, yt} = Sort[{ymin, ymax}]; width = xmax - xmin; line = Table[{{xmin, i}, {xmax, i + width}}, {i, yb, yt - width, h/seg}]; lend = line[[-1, 1, 2]]; line = { Line[line], Line[Table[{{xmin + i, yb}, {xmax, yb + width - i}}, {i, h/seg, width, h/seg}]], Line[Table[{{xmin, lend + i}, {xmax - (lend + width - yt) - i, yt}}, {i, h/seg, width + h/seg, h/seg}]] }; {{Opacity[.2], EdgeForm[], Rectangle[{xmin, ymin}, {xmax + gap, ymax}]}, {CapForm["Butt"], line}, {FaceForm[], Rectangle[{xmin, ymin}, {xmax, ymax}]}} ] barSolid[{{xmin_, xmax_}, {ymin_, ymax_}}, ___] := Rectangle[{xmin, ymin}, {xmax, ymax}] mixedBar[args : {{xmin_, xmax_}, {ymin_, ymax_}}, ___] := If[xmax < 3, barHatched[0, 5, 35][args], barSolid[args]] BarChart[ Transpose[{ {2, -1, 1.5, -3, 3, 2.5}, {2, -1, 1.5, -3, 3, 2.5} }], ChartElementFunction -> { mixedBar, barSolid } ] 

Mathematica graphics

The idea is to build custom CharElementFunctions for the bar appearances. To have variation with a set we need to make a ChartElementFunction which depends on the position of the bar. This is what the mixedBar function is for.

added 4 characters in body
Source Link
C. E.
  • 71.7k
  • 7
  • 144
  • 279

I have proposed that this isThe question might be considered a duplicate of this question, but for clarity I will show how by adapting the answer given there.

barHatched[gap_, h_, seg_][{{xmin_, xmax_}, {ymin_, ymax_}}, ___] := Module[{width, line, yt, yb, lend}, {yb, yt} = Sort[{ymin, ymax}]; width = xmax - xmin; line = Table[{{xmin, i}, {xmax, i + width}}, {i, yb, yt - width, h/seg}]; lend = line[[-1, 1, 2]]; line = { Line[line], Line[Table[{{xmin + i, yb}, {xmax, yb + width - i}}, {i, h/seg, width, h/seg}]], Line[Table[{{xmin, lend + i}, {xmax - (lend + width - yt) - i, yt}}, {i, h/seg, width + h/seg, h/seg}]] }; {{Opacity[.2], EdgeForm[], Rectangle[{xmin, ymin}, {xmax + gap, ymax}]}, {CapForm["Butt"], line}, {FaceForm[], Rectangle[{xmin, ymin}, {xmax, ymax}]}} ] barSolid[{{xmin_, xmax_}, {ymin_, ymax_}}, ___] := Rectangle[{xmin, ymin}, {xmax, ymax}] mixedBar[args : {{xmin_, xmax_}, {ymin_, ymax_}}, ___] := If[xmax < 3, barHatched[0, 5, 35][args], barSolid[args]] BarChart[ Transpose[{ {2, -1, 1.5, -3, 3, 2.5}, {2, -1, 1.5, -3, 3, 2.5} }], ChartElementFunction -> { mixedBar, barSolid } ] 

Mathematica graphics

The idea is to build custom CharElementFunctions for the bar appearances. To have variation with a set we need to make a ChartElementFunction which depends on the position of the bar. This is what the mixedBar function is for.

I have proposed that this is a duplicate of this question, but for clarity I will show how by adapting the answer given there.

barHatched[gap_, h_, seg_][{{xmin_, xmax_}, {ymin_, ymax_}}, ___] := Module[{width, line, yt, yb, lend}, {yb, yt} = Sort[{ymin, ymax}]; width = xmax - xmin; line = Table[{{xmin, i}, {xmax, i + width}}, {i, yb, yt - width, h/seg}]; lend = line[[-1, 1, 2]]; line = { Line[line], Line[Table[{{xmin + i, yb}, {xmax, yb + width - i}}, {i, h/seg, width, h/seg}]], Line[Table[{{xmin, lend + i}, {xmax - (lend + width - yt) - i, yt}}, {i, h/seg, width + h/seg, h/seg}]] }; {{Opacity[.2], EdgeForm[], Rectangle[{xmin, ymin}, {xmax + gap, ymax}]}, {CapForm["Butt"], line}, {FaceForm[], Rectangle[{xmin, ymin}, {xmax, ymax}]}} ] barSolid[{{xmin_, xmax_}, {ymin_, ymax_}}, ___] := Rectangle[{xmin, ymin}, {xmax, ymax}] mixedBar[args : {{xmin_, xmax_}, {ymin_, ymax_}}, ___] := If[xmax < 3, barHatched[0, 5, 35][args], barSolid[args]] BarChart[ Transpose[{ {2, -1, 1.5, -3, 3, 2.5}, {2, -1, 1.5, -3, 3, 2.5} }], ChartElementFunction -> { mixedBar, barSolid } ] 

Mathematica graphics

The idea is to build custom CharElementFunctions for the bar appearances. To have variation with a set we need to make a ChartElementFunction which depends on the position of the bar. This is what the mixedBar function is for.

The question might be considered a duplicate of this question, but for clarity I will show how by adapting the answer given there.

barHatched[gap_, h_, seg_][{{xmin_, xmax_}, {ymin_, ymax_}}, ___] := Module[{width, line, yt, yb, lend}, {yb, yt} = Sort[{ymin, ymax}]; width = xmax - xmin; line = Table[{{xmin, i}, {xmax, i + width}}, {i, yb, yt - width, h/seg}]; lend = line[[-1, 1, 2]]; line = { Line[line], Line[Table[{{xmin + i, yb}, {xmax, yb + width - i}}, {i, h/seg, width, h/seg}]], Line[Table[{{xmin, lend + i}, {xmax - (lend + width - yt) - i, yt}}, {i, h/seg, width + h/seg, h/seg}]] }; {{Opacity[.2], EdgeForm[], Rectangle[{xmin, ymin}, {xmax + gap, ymax}]}, {CapForm["Butt"], line}, {FaceForm[], Rectangle[{xmin, ymin}, {xmax, ymax}]}} ] barSolid[{{xmin_, xmax_}, {ymin_, ymax_}}, ___] := Rectangle[{xmin, ymin}, {xmax, ymax}] mixedBar[args : {{xmin_, xmax_}, {ymin_, ymax_}}, ___] := If[xmax < 3, barHatched[0, 5, 35][args], barSolid[args]] BarChart[ Transpose[{ {2, -1, 1.5, -3, 3, 2.5}, {2, -1, 1.5, -3, 3, 2.5} }], ChartElementFunction -> { mixedBar, barSolid } ] 

Mathematica graphics

The idea is to build custom CharElementFunctions for the bar appearances. To have variation with a set we need to make a ChartElementFunction which depends on the position of the bar. This is what the mixedBar function is for.

added 52 characters in body
Source Link
C. E.
  • 71.7k
  • 7
  • 144
  • 279

I have proposed that this is a duplicate of this question, but for clarity I will show how by adapting the answer given there.

barHatched[gap_, h_, seg_][{{xmin_, xmax_}, {ymin_, ymax_}}, ___] := Module[{width, line, yt, yb, lend}, {yb, yt} = Sort[{ymin, ymax}]; width = xmax - xmin; line = Table[{{xmin, i}, {xmax, i + width}}, {i, yb, yt - width, h/seg}]; lend = line[[-1, 1, 2]]; line = { Line[line], Line[Table[{{xmin + i, yb}, {xmax, yb + width - i}}, {i, h/seg, width, h/seg}]], Line[Table[{{xmin, lend + i}, {xmax - (lend + width - yt) - i, yt}}, {i, h/seg, width + h/seg, h/seg}]] }; {{Opacity[.2], EdgeForm[], Rectangle[{xmin, ymin}, {xmax + gap, ymax}]}, {CapForm["Butt"], line}, {FaceForm[], Rectangle[{xmin, ymin}, {xmax, ymax}]}} ] barSolid[{{xmin_, xmax_}, {ymin_, ymax_}}, ___] := Rectangle[{xmin, ymin}, {xmax, ymax}]   mixedBar[args : {{xmin_, xmax_}, {ymin_, ymax_}}, ___] := If[xmax < 3, barHatched[0, 5, 35][args], barSolid[args]] BarChart[ Transpose[{ {2, -1, 1.5, -3, 3, 2.5}, {2, -1, 1.5, -3, 3, 2.5} }], ChartElementFunction -> { mixedBar, barSolid } ] 

mixedBar[args : {{xmin_, xmax_}, {ymin_, ymax_}}, ___] := If[xmax < 3, barHatched[0, 5, 35][args], barSolid[args]]

BarChart[ Transpose[{ {2, -1, 1.5, -3, 3, 2.5}, {2, -1, 1.5, -3, 3, 2.5} }], ChartElementFunction -> { mixedBar, barSolid } ]

Mathematica graphics

The idea is to build custom CharElementFunctions for the bar appearances. To have variation with a set we need to make a ChartElementFunction which depends on the position of the bar. This is what the mixedBar function is for.

I have proposed that this is a duplicate of this question, but for clarity I will show how by adapting the answer given there.

barHatched[gap_, h_, seg_][{{xmin_, xmax_}, {ymin_, ymax_}}, ___] := Module[{width, line, yt, yb, lend}, {yb, yt} = Sort[{ymin, ymax}]; width = xmax - xmin; line = Table[{{xmin, i}, {xmax, i + width}}, {i, yb, yt - width, h/seg}]; lend = line[[-1, 1, 2]]; line = { Line[line], Line[Table[{{xmin + i, yb}, {xmax, yb + width - i}}, {i, h/seg, width, h/seg}]], Line[Table[{{xmin, lend + i}, {xmax - (lend + width - yt) - i, yt}}, {i, h/seg, width + h/seg, h/seg}]] }; {{Opacity[.2], EdgeForm[], Rectangle[{xmin, ymin}, {xmax + gap, ymax}]}, {CapForm["Butt"], line}, {FaceForm[], Rectangle[{xmin, ymin}, {xmax, ymax}]}} ] barSolid[{{xmin_, xmax_}, {ymin_, ymax_}}, ___] := Rectangle[{xmin, ymin}, {xmax, ymax}] 

mixedBar[args : {{xmin_, xmax_}, {ymin_, ymax_}}, ___] := If[xmax < 3, barHatched[0, 5, 35][args], barSolid[args]]

BarChart[ Transpose[{ {2, -1, 1.5, -3, 3, 2.5}, {2, -1, 1.5, -3, 3, 2.5} }], ChartElementFunction -> { mixedBar, barSolid } ]

Mathematica graphics

The idea is to build custom CharElementFunctions for the bar appearances. To have variation with a set we need to make a ChartElementFunction which depends on the position of the bar.

I have proposed that this is a duplicate of this question, but for clarity I will show how by adapting the answer given there.

barHatched[gap_, h_, seg_][{{xmin_, xmax_}, {ymin_, ymax_}}, ___] := Module[{width, line, yt, yb, lend}, {yb, yt} = Sort[{ymin, ymax}]; width = xmax - xmin; line = Table[{{xmin, i}, {xmax, i + width}}, {i, yb, yt - width, h/seg}]; lend = line[[-1, 1, 2]]; line = { Line[line], Line[Table[{{xmin + i, yb}, {xmax, yb + width - i}}, {i, h/seg, width, h/seg}]], Line[Table[{{xmin, lend + i}, {xmax - (lend + width - yt) - i, yt}}, {i, h/seg, width + h/seg, h/seg}]] }; {{Opacity[.2], EdgeForm[], Rectangle[{xmin, ymin}, {xmax + gap, ymax}]}, {CapForm["Butt"], line}, {FaceForm[], Rectangle[{xmin, ymin}, {xmax, ymax}]}} ] barSolid[{{xmin_, xmax_}, {ymin_, ymax_}}, ___] := Rectangle[{xmin, ymin}, {xmax, ymax}]   mixedBar[args : {{xmin_, xmax_}, {ymin_, ymax_}}, ___] := If[xmax < 3, barHatched[0, 5, 35][args], barSolid[args]] BarChart[ Transpose[{ {2, -1, 1.5, -3, 3, 2.5}, {2, -1, 1.5, -3, 3, 2.5} }], ChartElementFunction -> { mixedBar, barSolid } ] 

Mathematica graphics

The idea is to build custom CharElementFunctions for the bar appearances. To have variation with a set we need to make a ChartElementFunction which depends on the position of the bar. This is what the mixedBar function is for.

Post Undeleted by C. E.
Post Deleted by C. E.
Source Link
C. E.
  • 71.7k
  • 7
  • 144
  • 279
Loading