手抄报 安全手抄报 手抄报内容 手抄报图片 英语手抄报 清明节手抄报 节约用水手抄报

用Mathematica给图片添加文字(02)

时间:2024-10-11 21:15:42

由于百度经验过长会影响阅读,所以,把用Mathematica给图片添加文字分开来写。这是第二篇。

工具/原料

电脑

Mathematica

具体案例:

1、 用Labeled给圆加标注——“单位圆”:Labeled[Graphics[Circle[], Text[单位圆]] 注意,这里添加的文字是文本形式,不属于图片的一部分。

用Mathematica给图片添加文字(02)

2、 给文字添加会变化的标签,用鼠标点击标签,就会发生变化:DynamicModule[{c},Labeled[Graphics[{Dynamic[c], Disk[]}, ImageSize -> Tiny], Toggler[Dynamic[c], Reverse /@ ColorData["HTML", "ColorRules"], ImageSize -> Automatic]]]

用Mathematica给图片添加文字(02)

3、 绘制多条函数曲线,并用Inset添加标签:legendPlot[xl_List, d_, args___] := Plot[xl, 颊俄岿髭d, Epilog -> Inset[Panel[ Grid[MapIndexed[{Graphics[{ColorData[1, First@#2], Thick, Line[{{0, 0}, {1, 0}}]}, AspectRatio -> .1, ImageSize -> 20], #1} &, xl]]], Offset[{-2, -2}, Scaled[{1, 1}]], {Right, Top}], args];legendPlot[{Sin[x], Cos[x], Sinc[x]}, {x, 0, 10}]

用Mathematica给图片添加文字(02)

4、 用ChartLabels给条形统计图添加标签,并用Placed指定标签的位置:Table[BarChart[{1, 2, 3}, ChartLabels -> Placed[{"a", "b", "c"}, p], PlotLabel -> p], {p, {Bottom, Center, Top}}]

用Mathematica给图片添加文字(02)
用Mathematica给图片添加文字(02)
用Mathematica给图片添加文字(02)

5、 不明白为什么下面这个代码无法显示标签:Table[BarChart[{1, 2, 3}, ChartLabels -> Placed[{"a", "b", "c"}, p], PlotLabel -> p], {p, {"标签在底端", "标签居中", "标签居顶"}}]

用Mathematica给图片添加文字(02)
用Mathematica给图片添加文字(02)
用Mathematica给图片添加文字(02)

6、 给条形统计图内部添加标签:Table[PieChart[{1巳呀屋饔, 2, 3}, ChartLabels -> Placed[{"a", "b&qu泠贾高框ot;, "c"}, p], SectorOrigin -> {Automatic, 1}, PlotLabel -> p], {p, {"RadialInner", "RadialCenter", "RadialOuter"}}] 看下面的动态图:

用Mathematica给图片添加文字(02)

7、 给条形统计图外部添加标签:Table[PieChart[{1, 2, 3}, ChartLabels -> Placed[{"a", "b", "c"}, p], SectorOrigin -> {Automatic, 1}, PlotLabel -> p], {p, {"RadialInside", "RadialEdge", "RadialOutside"}}]

用Mathematica给图片添加文字(02)
© 手抄报圈