Graphics[primitives,options]
表示一个二维图形.
Graphics
Graphics[primitives,options]
表示一个二维图形.
更多信息和选项
- Graphics 以 StandardForm 形式显示一个图形. 在 InputForm 中,它显示为一个具体的指令列表.
- 可以使用下列图形基元: »
-
AASTriangle[α,β,a] 角边角三角形 Arrow[{{x1,y1},…}] 箭头 ASATriangle[α,c,β] 角边角三角形 BezierCurve[{pt1,pt2,…}] Bézier 曲线 BSplineCurve[{pt1,pt2,…}] B 样条曲线 Circle[{x,y},r] 圆 Circumsphere[{pt1,…}] 由三个点指定的外接圆 ConicHullRegion[…] 线性椎体 Disk[{x,y},r] 填充圆盘 FilledCurve[{seg1,seg2,…}] 填充曲线 GraphicsComplex[pts,prims] 图形对象的复合体 GraphicsGroup[{g1,g2,…}] 可作为群组选择的对象 HalfLine[{pt1,pt2}] 半无限长的直线,或称射线 HalfPlane[{pt1,pt2},v] 半无限平面 Image[…] 图像对象 InfiniteLine[{pt1,pt2}] 无限长直线 Inset[obj,…] 插入对象 JoinedCurve[{seg1,seg2,…}] 连接的曲线段 Line[{pt1,…}] 线段 Locator[{x,y}] 动态定位器 Parallelogram[pt,{v1,v2}] 平行四边形 Point[{x,y}] 点 Polygon[{pt1,…}] 多边形 Raster[array] 灰色或颜色方块的数组 Rectangle[{xmin,ymin},{xmax,ymax}] 矩形 SASTriangle[a,γ,b] 边角边三角形 Simplex[{pt1,…}] 单纯形 SSSTriangle[a,b,c] 边边边三角形 Text[expr,{x,y}] 文本 Triangle[{pt1,…}] 三角形 - 可以使用下列图形指令: »
-
AbsoluteDashing[{w1,…}] 指定绝对虚线 AbsolutePointSize[d] 指定绝对点的尺寸 AbsoluteThickness[w] 指定绝对线宽 Arrowheads[specs] 指定箭头 CapForm[type] 线帽指定 CMYKColor[c,m,y,k] 指定颜色 Dashing[{w1,…}] 指定虚线 Directive[g1,g2,…] 复合图形指令 EdgeForm[g] 指定绘制边 FaceForm[g] 指定绘制面 GrayLevel[i] 灰度指定 Hue[h] 色调指定 JoinForm[type] 线连接指定 Opacity[a] 透明度指定 PointSize[d] 点尺寸指定 RGBColor[r,g,b] 颜色指定 Texture[obj] 纹理指定 Thickness[w] 线宽指定 - 可以在任意层使用下面的封装:
-
Annotation[obj,label] 给出一个注解 Button[obj,action] 将 obj 作为一个按钮 Dynamic[obj] 动态更新当前值 EventHandler[obj,…] 一个事件处理器 Hyperlink[obj,URI] 将 obj 制作一个超链接 Mouseover[obj,over] 指定一个鼠标移动形式 PopupWindow[obj,cont] 弹出窗口 StatusArea[obj,label] 在状态栏区域指定一个标签 Style[obj,opts] 指定一个样式 Tooltip[obj,label] 添加一个工具提示 - 可以给出下列选项:
-
AlignmentPoint Center 在图形内对齐的缺省点 AspectRatio Automatic 高与宽的比 Axes False 是否绘制轴 AxesLabel None 坐标轴标签 AxesOrigin Automatic 坐标轴原点 AxesStyle {} 坐标轴样式指定 Background None 绘图的背景色 BaselinePosition Automatic 如何与环绕文本基线对齐 BaseStyle {} 图形的基本样式指定 ContentSelectable Automatic 是否允许进行内容选择 CoordinatesToolOptions Automatic 坐标工具的详细行为 Epilog {} 主图形之后执行的图形指令 FormatType TraditionalForm 文本的缺省样式类型 Frame False 是否在图形周围放置边框 FrameLabel None 边框标签 FrameStyle {} 边框的样式指定 FrameTicks Automatic 边框刻度 FrameTicksStyle {} 边框刻度的样式指定 GridLines None 绘制的网格线 GridLinesStyle {} 网格线的样式指定 ImageMargins 0. 图形周围的边幅 ImagePadding All 为标签等额外填充内容 ImageSize Automatic 图形的绝对尺寸 LabelStyle {} 标签的样式指定 Method Automatic 使用图形方式的细节 PlotLabel None 图形的一个整体标签 PlotRange All 图形值的范围 PlotRangeClipping False 是否在图形范围剪切 PlotRangePadding Automatic 填充图形值范围的程度 PlotRegion Automatic 填充的最后显示区域 PreserveImageOptions Automatic 当显示相同图形的新版本时,是否保存图形选项 Prolog {} 主图形之前执行的图形指令 RotateLabel True 是否在边框上旋转 y 标签 Ticks Automatic 坐标轴标记 TicksStyle {} 坐标轴标记的样式指定 - 可以给出图形的嵌套列表. 诸如 GrayLevel 的指定实际上只保持到直至包含它们的列表末尾.. »
- Style[obj,opts] 可用于将选项或指令 opts 应用到 obj. »
- 可以给出下列 Method 选项:
-
"AxesInFront" True 是否在图元上方绘制坐标轴 "FrameInFront" True 是否在图元上方绘制图形边框 "GridLinesInFront" False 是否在图元上方绘制网格线 "TransparentPolygonMesh" False 是否对毗邻多边形仔细绘制,以避免对边的双重渲染 - BaseStyle 的设置可以作为当前样式表中 "Graphics" 给出的默认样式的补充. AxesStyle、 LabelStyle 等设置可以作为 "GraphicsAxes"、"GraphicsLabel" 等给出的默认样式的补充.
- Graphics[] 以默认图形尺寸给出一个空图.
范例
打开所有单元 关闭所有单元基本范例 (2)
Graphics[{Thick, Green, Rectangle[{0, -1}, {2, 1}], Red, Disk[], Blue, Circle[{2, 0}], Yellow, Polygon[{{2, 0}, {4, 1}, {4, -1}}], Purple, Arrowheads[Large], Arrow[{{4, 3 / 2}, {0, 3 / 2}, {0, 0}}], Black, Dashed, Line[{{-1, 0}, {4, 0}}]}]从不同类型的数据用绘图函数自动创建 Graphics:
Plot[Evaluate[Table[BesselJ[n, x], {n, 4}]], {x, 0, 10}, Filling -> Axis]GraphPlot[Table[i -> Mod[i ^ 2, 104], {i, 0, 104}]]ReliefPlot[Table[i + Sin[i ^ 2 + j ^ 2], {i, -4, 4, .03}, {j, -4, 4, .03}], ColorFunction -> "SunsetColors"]范围 (13)
元素 (4)
绘图指令按 Graphics 给出的顺序来绘制:
Graphics[{Red, Disk[], Green, Rectangle[{0, 0}, {2, 2}], Blue, Disk[{2, 2}]}]Graphics[Polygon[{{0, 0}, {1, 1}, {0, 1}, {1, 0}}]]用 GraphicsComplex 可以共享顶点:
v = Table[15{Cos[t], Sin[t]}, {t, 0, 4Pi, 4Pi / 5}];Graphics[GraphicsComplex[v, {Point[{1, 2, 3, 4, 5, 6}], Green, Line[{1, 2, 3, 4, 5, 6}]}]]Graphics[{Circle[], Inset[x ^ 2 + y ^ 2 == 1, {0, 0}]}]指令 (5)
{Graphics[{Red, Disk[]}], Graphics[{Green, Disk[], Yellow, Opacity[.7], Disk[{0, 1}]}],
Graphics[{Hue[2 / 3, 1 / 2, 1], Rectangle[]}]}{Graphics[{Blue, Arrow[{{0, 0}, {2, 1}}]}], Graphics[{Thick, Blue, Line[{{0, 0}, {2, 1}}]}], Graphics[{Dashed, Red, Arrow[{{0, 0}, {2, 1}}]}], Graphics[{Thick, Dashed, Red, Line[{{0, 0}, {2, 1}}]}]}{Graphics[{Pink, Rectangle[]}], Graphics[{EdgeForm[Thick], Pink, Rectangle[]}], Graphics[{EdgeForm[Dashed], Pink, Rectangle[]}], Graphics[{EdgeForm[Directive[Thick, Dashed, Blue]], Pink, Rectangle[]}]}{Graphics[{Dashed, Red, Arrowheads[{-.1, .1}], Arrow[{{0, 0}, {2, 1}}]}], Graphics[{Blue, PointSize[Large], Point[{{0, 0}, {1, 1 / 2}, {2, 1}}]}]}指令可以应用到 Style 生成的单个对象:
Graphics[{Style[Disk[], Pink], Style[Rectangle[{2, -1}, {4, 1}], Blue]}]Graphics[{Pink, Disk[], {Blue, Disk[{1, 0}]}, Disk[{2, 0}]}]坐标 (4)
Graphics[Rectangle[{0, 4}, {10, 6}], Frame -> True, PlotRange -> {{0, 10}, {0, 10}}]Graphics[Rectangle[Scaled[{0, .4}], Scaled[{1, .6}]], Frame -> True, PlotRange -> {{0, 10}, {0, 10}}]Graphics[Rectangle[ImageScaled[{0, .4}], ImageScaled[{1, .6}]], Frame -> True, PlotRange -> {{0, 10}, {0, 10}}]Graphics[Rectangle[Offset[{10, 20}, {0, 0}], Offset[{-10, -20}, {1, 1}]], Frame -> True]选项 (71)
AlignmentPoint (1)
在 Inset 内指定坐标与封闭图形的中心对齐:
Table[Graphics[{Inset[Graphics[Circle[], ImageSize -> 30, AlignmentPoint -> {a, 0}], Center]}, ImageSize -> 70, Axes -> True, Ticks -> None], {a, {-1, 0, 1}}]Table[Graphics[{Inset[Graphics[Circle[], ImageSize -> 30, AlignmentPoint -> {0, a}], Center]}, ImageSize -> 70, Axes -> True, Ticks -> None], {a, {-1, 0, 1}}]AspectRatio (1)
对 AspectRatio 用数值值:
Table[Graphics[Circle[], AspectRatio -> 1 / k], {k, 1, 3}]Axes (2)
AxesLabel (2)
AxesOrigin (2)
AxesStyle (1)
BaselinePosition (3)
{x, Graphics[Circle[], ImageSize -> 50, BaselinePosition -> Center], y}指定图形的基线,Scaled 处理高度值的分式:
Table[{x, Graphics[Circle[], BaselinePosition -> Scaled[b], ImageSize -> 50]}, {b, {0, 0.5, 1}}]{x, Graphics[Circle[], Axes -> True, BaselinePosition -> Axis], y}{x, Graphics[Circle[{0, 1}], Axes -> True, BaselinePosition -> Axis], y}BaseStyle (2)
ContentSelectable (3)
Graphics[{Pink, Disk[], Rectangle[{2, -1}, {4, 1}]}, ContentSelectable -> True]Graphics[{Pink, Disk[], Rectangle[{2, -1}, {4, 1}]}, ContentSelectable -> False]Graphics[{Pink, Disk[], Rectangle[{2, -1}, {4, 1}]}, ContentSelectable -> Automatic]Epilog (1)
FormatType (3)
在缺省情况下,在图形中用 TraditionalForm 显示一个表达式:
Graphics[{Circle[], Text[Style[x ^ 2 + y ^ 2 == 1, 20]]}]用 StandardForm 显示表达式:
Graphics[{Circle[], Text[Style[x ^ 2 + y ^ 2 == 1, 20]]}, FormatType -> StandardForm]FormatType 设置会影响标签:
Graphics[Circle[], Axes -> True, AxesLabel -> {Cos[θ], Sin[θ]}, FormatType -> StandardForm]Frame (2)
FrameLabel (1)
FrameStyle (2)
FrameTicks (2)
Graphics[Circle[], Frame -> True, FrameTicks -> None]Graphics[Circle[], Frame -> True, FrameTicks -> Automatic]Graphics[Circle[], Frame -> True, FrameTicks -> {{None, Automatic}, {Automatic, None}}]FrameTicksStyle (2)
GridLines (3)
Graphics[Circle[], GridLines -> Automatic]Graphics[Circle[], Axes -> True, GridLines -> {{-1, 1}, {-1, 1}}]Graphics[Circle[], Axes -> True, GridLines -> {{{-1, Orange}, {-.5, Dotted}, {.5, Dotted}, {1, Orange}}, {-1, {-.5, Dotted}, {.5, Dotted}, 1}}]GridLinesStyle (1)
ImageMargins (3)
在 ImageSize 外不设置边幅:
Framed[Graphics[Disk[]]]Framed[Graphics[Disk[], ImageMargins -> 20]]Framed[Graphics[Disk[], ImageMargins -> {{5, 10}, {20, 30}}]]ImagePadding (4)
Graphics[{Thickness[.3], Pink, Circle[]}, ImagePadding -> None, Frame -> True, FrameLabel -> {x, y}]Framed[Graphics[{Thickness[.3], Pink, Circle[]}, ImagePadding -> All, Frame -> True, FrameLabel -> {x, y}], FrameMargins -> 0]Framed[Graphics[{Thickness[.3], Pink, Circle[]}, ImagePadding -> 40, Frame -> True]]Framed[Graphics[{Thickness[.2], Pink, Circle[]}, ImagePadding -> {{40, 10}, {20, 5}}, Frame -> True]]ImageSize (3)
Table[Graphics[Circle[], ImageSize -> s], {s, {Tiny, Small}}]{Graphics[Circle[], ImageSize -> 100], Graphics[Circle[{0, 0}, {1, 2}], ImageSize -> 100]}{Graphics[Circle[], ImageSize -> {100, 100}], Graphics[Circle[{0, 0}, {1, 2}], ImageSize -> {100, 100}]}LabelStyle (1)
Method (4)
"AxesInFront" (1)
"FrameInFront" (1)
"GridLinesInFront" (1)
"TransparentPolygonMesh" (1)
PlotLabel (2)
以 TraditionalForm 形式在图形顶部显示一个标签:
Graphics[Circle[], PlotLabel -> x ^ 2 + y ^ 2 == 1]用 Style 和其它排版函数修改标签如何显示:
Graphics[Circle[], PlotLabel -> Style[Framed[x ^ 2 + y ^ 2 == 1], 16, Red, Background -> Yellow]]PlotRange (3)
Graphics[{Pink, Disk[{0, 0}, 5]}, Frame -> True, PlotRange -> All]Graphics[{Pink, Disk[]}, PlotRange -> {{-1, 1}, {0, 1}}, Frame -> True]指定在 PlotRange 内剪切:
Graphics[{Pink, Disk[]}, PlotRange -> {{-1, 1}, {0, 1}}, PlotRangeClipping -> True, Frame -> True]PlotRange->s 等价于 PlotRange->{{-s,s},{-s,s}}:
Graphics[{Pink, Disk[{0, 0}, 5]}, Frame -> True, PlotRange -> 4]PlotRangeClipping (2)
PlotRangePadding (3)
Graphics[{Pink, Rectangle[]}, PlotRangePadding -> 1, Frame -> True]用 Scaled 坐标包含填充:
Graphics[{Pink, Rectangle[]}, PlotRangePadding -> Scaled[0.1], Frame -> True]Graphics[{Pink, Rectangle[]}, PlotRangePadding -> {{0.5, 1}, {0.3, 0.3}}, Frame -> True]PlotRegion (3)
Graphics[{Pink, Disk[]}, Frame -> True, FrameTicks -> False, Background -> LightBlue]Graphics[{Pink, Disk[]}, Frame -> True, FrameTicks -> False, PlotRegion -> {{0.25, 0.75}, {0.25, 0.75}}, Background -> LightBlue]ImagePadding 可以使用在图形周围增加填充:
Graphics[{Pink, Disk[]}, Frame -> True, FrameTicks -> False, ImagePadding -> 30, Background -> LightBlue]Prolog (1)
bg = Graphics[Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, VertexColors -> {Orange, Orange, White, White}], AspectRatio -> Full];Graphics[Circle[], Prolog -> Inset[bg, Scaled[{0, 0}], Scaled[{0, 0}]]]Plot[Sin[x], {x, 0, 10}, Prolog -> Inset[bg, Scaled[{0, 0}], Scaled[{0, 0}], Scaled[{1, 1}]]]RotateLabel (2)
Ticks (3)
应用 (1)
属性和关系 (5)
Graphics 的 StandardForm 形式是它的提交形式:
Graphics[Disk[]]InputForm 是文本表达式形式:
InputForm[%]Graphics 可以作为函数的输入:
makeDashed[ g_Graphics ] := g /. l_Line :> {Dashed, l}makeDashed[[image]]二维图形函数返回 Graphics:
ParametricPlot[{(v + u) Cos[u], (v + u) Sin[u]}, {u, 0, 4Pi}, {v, 0, 5}, Mesh -> False]ContourPlot[y + Sin[x ^ 2 + 3y], {x, -3, 3}, {y, -3, 3}, ColorFunction -> "Rainbow"]几种积分数据源返回 Graphics:
CountryData["World", "Shape"]GraphData["DoubleStarSnark"]多种 Import 和 Export 格式支持 Graphics:
First@Import["ExampleData/mathematica.pdf", "PageGraphics"]Import["ExampleData/coneflower.jpg", "Graphics"]巧妙范例 (2)
Dynamic@Module[{hour, min, sec, ht, mt, st}, Clock[];{hour, min, sec} = Take[DateList[], -3];ht = Pi / 2 - 2Pi hour / 12 - 2Pi min / 720;mt = Pi / 2 - 2Pi min / 60;st = Pi / 2 - 2Pi Floor[sec] / 60;Graphics[{Arrowheads[0.1], Arrow[{{0, 0}, 0.6{Cos[ht], Sin[ht]}}], Arrow[{{0, 0}, 0.85{Cos[mt], Sin[mt]}}], Line[{{0, 0}, 0.85{Cos[st], Sin[st]}}], PointSize[Medium], Table[Point[0.9{Cos[i], Sin[i]}], {i, 0, 2Pi, Pi / 6}], Point[{0, 0}], Circle[]}]]Graphics[Table[{Hue[t / 20], Circle[{Cos[2Pi t / 20], Sin[2Pi t / 20]}]}, {t, 20}]]参见
Plot ListPlot ListLinePlot ParametricPlot DensityPlot ArrayPlot RegionPlot ContourPlot Show Canvas Graphics3D Image GeometricScene Sound
前端令牌: Import
Function Repository: InteractiveGraphics
技术笔记
-
▪
- 图形结构
相关指南
-
▪
- 符号图形语言 ▪
- 平面几何 ▪
- 多边形 ▪
- WDF(Wolfram 数据框架)
历史
1988年引入 (1.0) | 在以下年份被更新:1996 (3.0) ▪ 2007 (6.0) ▪ 2008 (7.0) ▪ 2010 (8.0) ▪ 2014 (10.0) ▪ 2022 (13.1)
文本
Wolfram Research (1988),Graphics,Wolfram 语言函数,https://reference.wolfram.com/language/ref/Graphics.html (更新于 2022 年).
CMS
Wolfram 语言. 1988. "Graphics." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2022. https://reference.wolfram.com/language/ref/Graphics.html.
APA
Wolfram 语言. (1988). Graphics. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/Graphics.html 年
BibTeX
@misc{reference.wolfram_2026_graphics, author="Wolfram Research", title="{Graphics}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/Graphics.html}", note=[Accessed: 10-July-2026]}
BibLaTeX
@online{reference.wolfram_2026_graphics, organization={Wolfram Research}, title={Graphics}, year={2022}, url={https://reference.wolfram.com/language/ref/Graphics.html}, note=[Accessed: 10-July-2026]}