如何绘制有界整数方程的 mathematica 解返回的列表
所以我有一组有界丢番图方程,用于指定平面上的线。我想让mathematica 绘制这些方程中两个方程的交集,这样我就可以看到它们的样子。
到目前为止我有类似的东西:
求解[0 < x - y < 3&& -1< 2x-y< 2、{x,y},整数]
返回一些结构,例如:
{{x ->; -2,y-> -4},{x-> -1,y-> -3},{x-> -1,y-> -2},{x-> 0, y-> -1}}
但是我现在怎样才能让mathematica绘制这个图以便我可以看到结果的形状。最好我希望绘图将每个“点”视为 1x1 正方形。
另外,我想知道是否有更好的方法来做这些事情。谢谢。
So I have a set of bounded diophantine equations that specify lines on the plane. I want to make mathematica plot the intersection of two of these equations so I can see what they look like.
So far I have something like:
Solve[0 < x - y < 3 && -1 < 2 x - y < 2, {x, y}, Integers]
which returns some structure like:
{{x -> -2, y -> -4}, {x -> -1, y -> -3}, {x -> -1, y -> -2}, {x -> 0,
y -> -1}}
but how can I now make mathematica plot this so I can see the resulting shape. Preferably I would like the plot to consider every 'point' to be a 1x1 square.
Also, I wonder if there is a better way to do such things. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通过转换
Solve[]
返回的列表来定义要绘制的数据。 更一般地,您可以使用以下技巧使
Solve
以列表格式(而不是一组规则)返回解决方案:对于绘图,在许多替代方案中,您可以使用 < code>ListPlot 以
获得以下输出
您可以使用许多样式和其他选项进一步细化它的列表图。例如,您可以加入点
以获得
编辑:要使用标记位置和大小,有多种选择。使用
ListPlot
,您可以通过以下两种方式获得所需的内容:在这两种情况下,您都需要使用
Epilog
,否则连接点的线会被标记遮挡。两种替代方案都会产生以下输出:或者,您可以使用
Graphics
、RegionPlot
、ContourPlot
、BubbleChart
对data
进行适当的转换,以获得与ListPlot
类似的结果代码>输出 多于。使用图形基元:
使用气泡图:
使用 RegionPlot:
使用 ContourPlot:
Define the data you wish to plot by transforming the list
Solve[]
returns. This can done asMore generally, you can make
Solve
return the solution in a list format (rather than as a set of rules) using the following trick:For plotting, among many alternatives, you can use
ListPlot
asto get the following output
You can further refine it using many styling and other options of
ListPlot
. For example, you can join the pointsto get
EDIT: To play with the marker placement and size there are several alternatives. Using
ListPlot
you can get what you need in either of the two ways:In both cases, you need to use
Epilog
, otherwise the lines joining points are occluded by the markers. Both alternatives produce the following output:Alternatively, you can use
Graphics
,RegionPlot
,ContourPlot
,BubbleChart
with appropriate transformations ofdata
to get results similar to the one inListPlot
output above.Using Graphics primitives:
Using BubbleChart:
Using RegionPlot:
Using ContourPlot:
可能是
也可以使用提取点来绘制
may be
Can also extract the points to plot using