main.tex

main.tex

我想做以下事情,但我不知道在 Latex 中是否可行,而且真的不知道从哪里开始,希望有人能给我一些启发!

所以我有一个 PDF 格式的图形,要么只有外部描边,要么用白色填充,如下所示:

图。1

我想将其填充为堆积条形图,如下所示:

图2

请注意,它不必完全填满。

理想情况下,它将被包装在 \fillperson 命令中,我们可以像这样调用:

 \fillperson{team player}{25}

其中 25 表示 25%

这可能吗?谢谢!

答案1

我使用 Inkscape 描摹图像,并将svg2tikz其导出到 TikZ 路径。该路径经过了少许修改。两个文件manclip.texmandraw.tex包含此路径,但在第一种情况下它是\clip路径,在第二种情况下它是\draw路径。

该宏\manbar有两个参数。第一个参数是用逗号分隔的列表fraction/color,用于填充。例如0.25/blue,0.5/red,它将用蓝色填充下部 25%,用红色填充 25% 到 50% 之间。第二个参数是用逗号分隔的标签列表(必须长度相同),这些标签打印在彩色区域上方。

在此处输入图片描述

main.tex

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,backgrounds}
\newcommand\manbar[2]{%
\begin{tikzpicture}[x=0.02cm,y=0.02cm,yscale=-1]
\begin{scope}[even odd rule]
\input{manclip}
\foreach [remember=\y as \lasty (initially 0),count=\i] \y/\clr in {#1}
\fill [\clr]
   ($(current bounding box.south west)!\lasty!(current bounding box.north west)$) rectangle
   ($(current bounding box.south east)!\y!(current bounding box.north east)$)
   coordinate [midway] (n\i);
\end{scope}
\input{mandraw}
\foreach [count=\i] \txt in {#2}
  \node [font=\footnotesize\bfseries] at (n\i) {\txt};
\end{tikzpicture}}
\begin{document}
\manbar{0.25/orange,0.45/blue!40,0.7/green!70!blue}{Team Player,Organized,Initiative}
\manbar{0.5/violet}{Dude}
\manbar{0.5/cyan,1/blue!50}{Stuff,Weird}
\end{document}

manclip.tex

\clip (155.6612,657.9729) .. controls (154.1719,657.2964) and
  (153.7316,656.4705) .. (153.8520,654.5790) .. controls (153.9342,653.2889) and
  (154.1107,652.7802) .. (154.8762,651.6273) .. controls (155.3849,650.8612) and
  (155.6807,650.2344) .. (155.5337,650.2344) .. controls (155.1095,650.2344) and
  (153.2862,646.0406) .. (153.0514,644.5244) .. controls (152.9339,643.7670) and
  (152.6620,641.1332) .. (152.4467,638.6714) .. controls (152.2314,636.2096) and
  (151.9456,633.0205) .. (151.8114,631.5844) .. controls (151.6770,630.1484) and
  (151.3899,626.5117) .. (151.1730,623.5027) .. controls (150.5343,614.6442) and
  (150.3744,613.1510) .. (149.8686,611.3181) .. controls (149.3149,609.3115) and
  (148.6667,604.7009) .. (148.4428,601.1758) .. controls (148.3012,598.9472) and
  (148.2490,598.7546) .. (147.8236,598.8896) .. controls (147.3934,599.0262) and
  (147.3538,598.8473) .. (147.2880,596.4742) .. controls (147.2289,594.3459) and
  (147.1699,594.0169) .. (146.9396,594.5331) .. controls (146.6633,595.1525) and
  (146.6544,595.1473) .. (144.5395,593.0830) .. controls (142.7997,591.3851) and
  (142.3653,590.8072) .. (142.1320,589.8808) .. controls (141.9754,589.2590) and
  (141.5728,588.3904) .. (141.2374,587.9505) .. controls (140.6771,587.2160) and
  (140.4189,586.5939) .. (139.1706,582.9702) .. controls (138.9350,582.2863) and
  (138.4039,581.2062) .. (137.9903,580.5698) .. controls (136.9579,578.9815) and
  (136.1924,575.6597) .. (136.6383,574.7032) .. controls (136.8141,574.3263) and
  (136.9887,572.8992) .. (137.0268,571.5315) .. controls (137.0652,570.1639) and
  (137.3871,567.0315) .. (137.7426,564.5707) .. controls (138.0983,562.1099) and
  (138.3892,559.4138) .. (138.3892,558.5795) .. controls (138.3892,557.7045) and
  (138.6022,556.4439) .. (138.8921,555.6008) .. controls (139.1687,554.7970) and
  (139.3360,553.9858) .. (139.2639,553.7981) .. controls (139.0832,553.3274) and
  (139.5989,550.2379) .. (139.9231,549.8470) .. controls (140.2949,549.3989) and
  (143.9219,547.5978) .. (147.5898,546.0398) .. controls (150.9170,544.6265) and
  (151.4637,544.2852) .. (151.7190,543.4616) .. controls (151.8087,543.1719) and
  (152.0916,542.6379) .. (152.3471,542.2748) .. controls (153.0611,541.2607) and
  (152.9357,538.0859) .. (152.1817,538.0859) .. controls (152.0040,538.0859) and
  (151.6649,537.5795) .. (151.4285,536.9606) .. controls (150.9658,535.7491) and
  (151.0292,533.2299) .. (151.6062,529.9011) .. controls (151.9477,527.9305) and
  (153.0311,526.6329) .. (155.3210,525.4519) .. controls (157.3560,524.4023) and
  (158.4476,524.4107) .. (160.3963,525.4911) .. controls (162.7486,526.7951) and
  (163.4735,528.2657) .. (164.0180,532.8382) .. controls (164.3307,535.4662) and
  (164.1649,537.1784) .. (163.5183,538.0008) .. controls (162.9642,538.7052) and
  (162.3965,541.3303) .. (162.6123,542.1903) .. controls (162.8288,543.0521) and
  (163.7559,543.4194) .. (167.3311,544.0595) .. controls (168.9137,544.3427) and
  (170.8437,544.7932) .. (171.6201,545.0604) .. controls (172.3965,545.3274) and
  (173.2921,545.5460) .. (173.6103,545.5460) .. controls (174.3953,545.5460) and
  (175.1664,547.1132) .. (176.3172,551.0473) .. controls (176.8124,552.7400) and
  (177.6522,555.5447) .. (178.1835,557.2798) .. controls (178.7148,559.0150) and
  (179.3913,561.7006) .. (179.6867,563.2478) .. controls (180.0432,565.1150) and
  (180.5015,566.6130) .. (181.0494,567.7025) -- (181.8748,569.3440) --
  (181.8219,575.0878) .. controls (181.7712,580.6020) and (181.7467,580.8616) ..
  (181.2129,581.5840) .. controls (180.7410,582.2222) and (180.6796,582.5352) ..
  (180.8084,583.6480) .. controls (181.0444,585.6878) and (180.2878,589.6018) ..
  (179.2666,591.6232) -- (178.4128,593.3134) -- (178.8006,595.4775) .. controls
  (179.0140,596.6677) and (179.3145,597.9214) .. (179.4685,598.2633) .. controls
  (179.6224,598.6052) and (179.7781,599.6123) .. (179.8146,600.5013) .. controls
  (179.9265,603.2414) and (180.3490,605.9962) .. (181.0152,608.3342) .. controls
  (181.3660,609.5652) and (181.9529,611.7407) .. (182.3194,613.1688) .. controls
  (183.0568,616.0425) and (183.0494,616.1965) .. (181.9052,621.7622) .. controls
  (181.2467,624.9654) and (180.9164,628.9057) .. (180.7486,635.5632) --
  (180.6139,640.9095) -- (181.4020,644.0179) .. controls (181.8645,645.8422) and
  (182.3882,647.3382) .. (182.6696,647.6395) .. controls (182.9332,647.9220) and
  (183.1491,648.2720) .. (183.1491,648.4175) .. controls (183.1491,649.0082) and
  (186.8541,650.0651) .. (189.4818,650.2240) .. controls (191.5787,650.3507) and
  (191.7336,650.3986) .. (192.0845,651.0257) .. controls (193.6168,653.7642) and
  (188.1376,655.2751) .. (181.4084,653.9698) .. controls (179.3034,653.5614) and
  (177.5317,653.4049) .. (174.6944,653.3767) .. controls (169.5361,653.3253) and
  (169.7211,653.4515) .. (169.7211,649.9879) .. controls (169.7211,647.9171) and
  (169.9030,646.3986) .. (170.4869,643.5936) -- (171.2526,639.9149) --
  (170.8900,634.8172) .. controls (170.6905,632.0135) and (170.5205,629.4958) ..
  (170.5120,629.2222) .. controls (170.5050,628.9486) and (170.0984,627.4192) ..
  (169.6115,625.8233) .. controls (169.1146,624.1947) and (168.7262,622.3896) ..
  (168.7262,621.7091) .. controls (168.7262,619.9474) and (167.0023,613.3595) ..
  (164.9448,607.2583) .. controls (162.9800,601.4323) and (162.9365,601.3917) ..
  (162.4936,604.9772) .. controls (161.9225,609.6004) and (161.0963,620.8190) ..
  (160.9920,625.3679) .. controls (160.9800,625.8466) and (161.0482,627.8048) ..
  (161.1419,629.7196) .. controls (161.2962,632.8809) and (161.4009,633.4586) ..
  (162.2804,636.0053) .. controls (162.8130,637.5478) and (163.4688,639.8976) ..
  (163.7376,641.2273) .. controls (164.3502,644.2565) and (164.1311,646.6140) ..
  (163.0409,648.7269) .. controls (162.4578,649.8569) and (162.3045,650.5220) ..
  (162.2037,652.3595) .. controls (162.0184,655.7384) and (161.0711,657.4815) ..
  (159.0531,658.1574) .. controls (157.8587,658.5574) and (156.8233,658.5012) ..
  (155.6606,657.9732) -- cycle(146.0002,578.4738) ..
  controls (145.9173,578.2574) and (145.8494,577.8236) .. (145.8494,577.5096) ..
  controls (145.8494,577.1957) and (145.6917,576.8078) .. (145.4987,576.6477) ..
  controls (145.3057,576.4876) and (145.0872,575.7186) .. (145.0128,574.9388) ..
  controls (144.9383,574.1589) and (144.8628,573.4090) .. (144.8452,573.2722) ..
  controls (144.7861,572.8199) and (145.3935,570.0504) .. (145.6863,569.4378) ..
  controls (145.9883,568.8058) and (146.6922,568.3793) .. (146.4677,568.9643) ..
  controls (146.3972,569.1481) and (146.5651,569.7405) .. (146.8407,570.2810) ..
  controls (147.2658,571.1148) and (147.3417,571.7468) .. (147.3417,574.4525) ..
  controls (147.3417,576.9691) and (147.2573,577.7706) .. (146.9401,578.2543) ..
  controls (146.4747,578.9646) and (146.2125,579.0259) .. (146.0007,578.4738) --
  cycle;

mandraw.tex

\draw [thick] (155.6612,657.9729) .. controls (154.1719,657.2964) and
  (153.7316,656.4705) .. (153.8520,654.5790) .. controls (153.9342,653.2889) and
  (154.1107,652.7802) .. (154.8762,651.6273) .. controls (155.3849,650.8612) and
  (155.6807,650.2344) .. (155.5337,650.2344) .. controls (155.1095,650.2344) and
  (153.2862,646.0406) .. (153.0514,644.5244) .. controls (152.9339,643.7670) and
  (152.6620,641.1332) .. (152.4467,638.6714) .. controls (152.2314,636.2096) and
  (151.9456,633.0205) .. (151.8114,631.5844) .. controls (151.6770,630.1484) and
  (151.3899,626.5117) .. (151.1730,623.5027) .. controls (150.5343,614.6442) and
  (150.3744,613.1510) .. (149.8686,611.3181) .. controls (149.3149,609.3115) and
  (148.6667,604.7009) .. (148.4428,601.1758) .. controls (148.3012,598.9472) and
  (148.2490,598.7546) .. (147.8236,598.8896) .. controls (147.3934,599.0262) and
  (147.3538,598.8473) .. (147.2880,596.4742) .. controls (147.2289,594.3459) and
  (147.1699,594.0169) .. (146.9396,594.5331) .. controls (146.6633,595.1525) and
  (146.6544,595.1473) .. (144.5395,593.0830) .. controls (142.7997,591.3851) and
  (142.3653,590.8072) .. (142.1320,589.8808) .. controls (141.9754,589.2590) and
  (141.5728,588.3904) .. (141.2374,587.9505) .. controls (140.6771,587.2160) and
  (140.4189,586.5939) .. (139.1706,582.9702) .. controls (138.9350,582.2863) and
  (138.4039,581.2062) .. (137.9903,580.5698) .. controls (136.9579,578.9815) and
  (136.1924,575.6597) .. (136.6383,574.7032) .. controls (136.8141,574.3263) and
  (136.9887,572.8992) .. (137.0268,571.5315) .. controls (137.0652,570.1639) and
  (137.3871,567.0315) .. (137.7426,564.5707) .. controls (138.0983,562.1099) and
  (138.3892,559.4138) .. (138.3892,558.5795) .. controls (138.3892,557.7045) and
  (138.6022,556.4439) .. (138.8921,555.6008) .. controls (139.1687,554.7970) and
  (139.3360,553.9858) .. (139.2639,553.7981) .. controls (139.0832,553.3274) and
  (139.5989,550.2379) .. (139.9231,549.8470) .. controls (140.2949,549.3989) and
  (143.9219,547.5978) .. (147.5898,546.0398) .. controls (150.9170,544.6265) and
  (151.4637,544.2852) .. (151.7190,543.4616) .. controls (151.8087,543.1719) and
  (152.0916,542.6379) .. (152.3471,542.2748) .. controls (153.0611,541.2607) and
  (152.9357,538.0859) .. (152.1817,538.0859) .. controls (152.0040,538.0859) and
  (151.6649,537.5795) .. (151.4285,536.9606) .. controls (150.9658,535.7491) and
  (151.0292,533.2299) .. (151.6062,529.9011) .. controls (151.9477,527.9305) and
  (153.0311,526.6329) .. (155.3210,525.4519) .. controls (157.3560,524.4023) and
  (158.4476,524.4107) .. (160.3963,525.4911) .. controls (162.7486,526.7951) and
  (163.4735,528.2657) .. (164.0180,532.8382) .. controls (164.3307,535.4662) and
  (164.1649,537.1784) .. (163.5183,538.0008) .. controls (162.9642,538.7052) and
  (162.3965,541.3303) .. (162.6123,542.1903) .. controls (162.8288,543.0521) and
  (163.7559,543.4194) .. (167.3311,544.0595) .. controls (168.9137,544.3427) and
  (170.8437,544.7932) .. (171.6201,545.0604) .. controls (172.3965,545.3274) and
  (173.2921,545.5460) .. (173.6103,545.5460) .. controls (174.3953,545.5460) and
  (175.1664,547.1132) .. (176.3172,551.0473) .. controls (176.8124,552.7400) and
  (177.6522,555.5447) .. (178.1835,557.2798) .. controls (178.7148,559.0150) and
  (179.3913,561.7006) .. (179.6867,563.2478) .. controls (180.0432,565.1150) and
  (180.5015,566.6130) .. (181.0494,567.7025) -- (181.8748,569.3440) --
  (181.8219,575.0878) .. controls (181.7712,580.6020) and (181.7467,580.8616) ..
  (181.2129,581.5840) .. controls (180.7410,582.2222) and (180.6796,582.5352) ..
  (180.8084,583.6480) .. controls (181.0444,585.6878) and (180.2878,589.6018) ..
  (179.2666,591.6232) -- (178.4128,593.3134) -- (178.8006,595.4775) .. controls
  (179.0140,596.6677) and (179.3145,597.9214) .. (179.4685,598.2633) .. controls
  (179.6224,598.6052) and (179.7781,599.6123) .. (179.8146,600.5013) .. controls
  (179.9265,603.2414) and (180.3490,605.9962) .. (181.0152,608.3342) .. controls
  (181.3660,609.5652) and (181.9529,611.7407) .. (182.3194,613.1688) .. controls
  (183.0568,616.0425) and (183.0494,616.1965) .. (181.9052,621.7622) .. controls
  (181.2467,624.9654) and (180.9164,628.9057) .. (180.7486,635.5632) --
  (180.6139,640.9095) -- (181.4020,644.0179) .. controls (181.8645,645.8422) and
  (182.3882,647.3382) .. (182.6696,647.6395) .. controls (182.9332,647.9220) and
  (183.1491,648.2720) .. (183.1491,648.4175) .. controls (183.1491,649.0082) and
  (186.8541,650.0651) .. (189.4818,650.2240) .. controls (191.5787,650.3507) and
  (191.7336,650.3986) .. (192.0845,651.0257) .. controls (193.6168,653.7642) and
  (188.1376,655.2751) .. (181.4084,653.9698) .. controls (179.3034,653.5614) and
  (177.5317,653.4049) .. (174.6944,653.3767) .. controls (169.5361,653.3253) and
  (169.7211,653.4515) .. (169.7211,649.9879) .. controls (169.7211,647.9171) and
  (169.9030,646.3986) .. (170.4869,643.5936) -- (171.2526,639.9149) --
  (170.8900,634.8172) .. controls (170.6905,632.0135) and (170.5205,629.4958) ..
  (170.5120,629.2222) .. controls (170.5050,628.9486) and (170.0984,627.4192) ..
  (169.6115,625.8233) .. controls (169.1146,624.1947) and (168.7262,622.3896) ..
  (168.7262,621.7091) .. controls (168.7262,619.9474) and (167.0023,613.3595) ..
  (164.9448,607.2583) .. controls (162.9800,601.4323) and (162.9365,601.3917) ..
  (162.4936,604.9772) .. controls (161.9225,609.6004) and (161.0963,620.8190) ..
  (160.9920,625.3679) .. controls (160.9800,625.8466) and (161.0482,627.8048) ..
  (161.1419,629.7196) .. controls (161.2962,632.8809) and (161.4009,633.4586) ..
  (162.2804,636.0053) .. controls (162.8130,637.5478) and (163.4688,639.8976) ..
  (163.7376,641.2273) .. controls (164.3502,644.2565) and (164.1311,646.6140) ..
  (163.0409,648.7269) .. controls (162.4578,649.8569) and (162.3045,650.5220) ..
  (162.2037,652.3595) .. controls (162.0184,655.7384) and (161.0711,657.4815) ..
  (159.0531,658.1574) .. controls (157.8587,658.5574) and (156.8233,658.5012) ..
  (155.6606,657.9732) -- cycle;
  \draw (146.0002,578.4738) ..
  controls (145.9173,578.2574) and (145.8494,577.8236) .. (145.8494,577.5096) ..
  controls (145.8494,577.1957) and (145.6917,576.8078) .. (145.4987,576.6477) ..
  controls (145.3057,576.4876) and (145.0872,575.7186) .. (145.0128,574.9388) ..
  controls (144.9383,574.1589) and (144.8628,573.4090) .. (144.8452,573.2722) ..
  controls (144.7861,572.8199) and (145.3935,570.0504) .. (145.6863,569.4378) ..
  controls (145.9883,568.8058) and (146.6922,568.3793) .. (146.4677,568.9643) ..
  controls (146.3972,569.1481) and (146.5651,569.7405) .. (146.8407,570.2810) ..
  controls (147.2658,571.1148) and (147.3417,571.7468) .. (147.3417,574.4525) ..
  controls (147.3417,576.9691) and (147.2573,577.7706) .. (146.9401,578.2543) ..
  controls (146.4747,578.9646) and (146.2125,579.0259) .. (146.0007,578.4738) --
  cycle;

相关内容