Skip to main content

Two dimensional plots

Most examples were adapted from the official pages of Wolfram Language Documentation Center.

The algorithms and implementations of those functions are the intellectual property of Wolfram Research. WLJS Team only reimplemented underlying low-level primitives such as `Line`, `Point`, `Polygon`, and etc.

Download original notebook

Contour Plot

Generates a contour plot of ff as a function of {x,y}\{x,y\}

ContourPlot[
  Cos[x] + Cos[y], {x, 0, 4 Pi}, {y, 0, 4 Pi}
, PerformanceGoal->"Speed"]
(*VB[*)(FrontEndRef["41a6a71f-5798-4386-9609-f87cceaa5041"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKmxgmmiWaG6bpmppbWuiaGFuY6VqaGVjqplmYJyenJiaaGpgYAgB3jhUk"*)(*]VB*)

Or plot contour lines for which the equation is satisfied

ContourPlot[(*SpB[*)Power[x(*|*),(*|*)2](*]SpB*) - (*SpB[*)Power[y(*|*),(*|*)2](*]SpB*) == (*SpB[*)Power[x(*|*),(*|*)3](*]SpB*), {x, -2, 2}, {y, -2, 2}]
(*VB[*)(FrontEndRef["17562242-ec14-4f0d-a6e4-2105f8af166b"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKG5qbmhkZmRjppiYbmuiapBmk6CaapZroGhkamKZZJKYZmpklAQB1eRU3"*)(*]VB*)

List-version

ListContourPlot[Table[Sin[i + (*SpB[*)Power[j(*|*),(*|*)2](*]SpB*)], {i, 0, 3, 0.2}, {j, 0, 3, 0.2}], ColorFunction -> "SunsetColors"]
(*VB[*)(FrontEndRef["5f39bfbd-9f05-402a-98f9-5ff6032a27bb"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKm6YZWyalJaXoWqYZmOqaGBgl6lpapFnqmqalmRkYGyUamSclAQCKzxXd"*)(*]VB*)

Density Plot

Make a simple styled density plot with a custom color function

CoolColor[ z_ ] := RGBColor[z, 1 - z, 1];

DensityPlot[Sin[x y], {x, -1, 1}, {y, -1, 1}, 
 ColorFunction -> CoolColor]
(*VB[*)(FrontEndRef["b287a631-d44e-4654-a042-484cce2fe6f2"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKJxlZmCeaGRvqppiYpOqamJma6CYamBjpmliYJCenGqWlmqUZAQB7FRVy"*)(*]VB*)

Vector plot

Generates a vector plot of the vector field {vx,vy}\{v_x, v_y\} as a function of xx and yy

VectorPlot[{x + y, y - x}, {x, -3, 3}, {y, -3, 3}]
(*VB[*)(FrontEndRef["c90ec165-9fa7-4a1f-aa27-1346176a9452"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKJ1sapCYbmpnqWqYlmuuaJBqm6SYmGpnrGhqbmBmamyVampgaAQCGaRVC"*)(*]VB*)

A list version is also available

ListVectorPlot[Table[{y, -x}, {x, -3, 3, 0.2}, {y, -3, 3, 0.2}]]
(*VB[*)(FrontEndRef["d4e33cf6-a00c-45b4-9708-f0217dd0fbff"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKp5ikGhsnp5npJhoYJOuamCaZ6FqaG1jophkYGZqnpBikJaWlAQCG9hX8"*)(*]VB*)

Stream plot

Generates a stream plot of the vector field

StreamPlot[{-1 - (*SpB[*)Power[x(*|*),(*|*)2](*]SpB*) + y, 1 + x - (*SpB[*)Power[y(*|*),(*|*)2](*]SpB*)}, {x, -3, 3}, {y, -3, 3}]
(*VB[*)(FrontEndRef["b5c7f485-bb4a-43ff-852e-a6c895c4068e"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKJ5kmm6eZWJjqJiWZJOqaGKel6VqYGqXqJpolW1iaJpsYmFmkAgCNLBXl"*)(*]VB*)

Matrixes & Arrays

Plots a 2D array or matrix

MatrixPlot[
 Fourier[Table[
   UnitStep[i, 4 - i] UnitStep[j, 7 - j], {i, -7, 7}, {j, -7, 
    7}]]]
(*VB[*)(FrontEndRef["40eb9c0a-60bf-413f-8d4b-0b440d1a6312"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKmxikJlkmGyTqmhkkpemaGBqn6VqkmCTpGiSZmBikGCaaGRsaAQCIDxWF"*)(*]VB*)

Another example

MatrixPlot[PauliMatrix[3]]
(*VB[*)(FrontEndRef["490bad61-47c1-46f0-b359-853531993ed7"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKm1gaJCWmmBnqmpgnAwmzNAPdJGNTS10LU2NTY0NLS+PUFHMAebIU7g=="*)(*]VB*)

Array plot

Generates a plot, where values are shown in a discrete array of blocks

ArrayPlot[{{1, 0, 0, Pink}, {1, 1, 0, Pink}, {1, 0, 1, Red}}]
(*VB[*)(FrontEndRef["d40c935a-36b0-4e55-afd9-4033c89cc91c"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKp5gYJFsamybqGpslGeiapJqa6iampVjqmhgYGydbWCYnWxomAwCCMxWj"*)(*]VB*)