Choose Language Hide Translation Bar
Staff

## Ways to draw a heart in JMP?

Here's one way to do it, using parametric equations found at Math World: Heart Curve.

``````New Table( "heart",
New Column( "t", Set Values( Index( 0, 2 * Pi(), 0.1 ) ) ),
New Column( "x", Formula( 16 * Power( Sin(t), 3 ) ) ),
New Column( "y", Formula( 13 * Cos(t) - 5 * Cos(2 * t) - 2 * Cos(3 * t) - Cos(4 * t) ) )
);

Graph Builder( Show Control Panel( 0 ), Variables( X( :x ), Y( :y ), Legend( 1 )), Elements( Formula( X, Y ) ),
SendToReport( Dispatch( {}, "400", ScaleBox,
{Legend Model( 1, Properties( 0, {Line Color( "Red" ), Line Width( 4 )} ) )})
)
);
``````

1 ACCEPTED SOLUTION

Accepted Solutions
Community Trekker

## Re: Ways to draw a heart in JMP?

Here's a way to do it using drawing functions (no data table required):

``````Names Default To Here( 1 );

func_HeartFilledPolygon = Function(
{},
{_HeartShapeX, _HeartShapeY, t=0::2*Pi()::0.1},

_HeartShapeY = 13 * Cos( t ) - 5 * Cos( 2 * t ) - 2 * Cos( 3 * t ) - Cos( 4 * t ) ;
_HeartShapeX = Power( Sin( t ), 3 );

Eval( Substitute( Expr( Polygon( Expr( shape_x ), Expr( shape_y ) ) ), Expr( shape_x ), _HeartShapeX, Expr( shape_y ), _HeartShapeY ) );
);

new window("Belated Valentines Day",
_ob=OutlineBox("Heart",
_hlb=HListBox(
_grbox=Graph Box(
X Scale(-1.5, 1.5),
Y Scale(-20, 15),
XName(""),
YName(""),
Fill Color("red");
func_HeartFilledPolygon();
)
)
)
);``````

27 REPLIES 27
Highlighted
Staff

## Re: Ways to draw a heart in JMP?

``````dt = Open("\$SAMPLE_DATA/Big Class.jmp");
dt << colorByColumn(:sex);
dt << Bubble Plot(
X( :height ),
Y( :weight ),
Bubble Size( 30 ),
Set Custom Path(
"M-0.0887761244941046,0.850401752915005 C-0.132509691601686,0.801393885307063 -0.241710361277604,0.705852240487693 -0.331444173501431,0.638087060729371 C-0.59731840814714,0.437304249670604 -0.633503948597818,0.408246894851737 -0.741454403833403,0.308845722351141 C-0.940467837688774,0.125593337736938 -1.02498556965361,-0.0585152381026677 -1.02469594220815,-0.308151809968423 C-1.02455462493824,-0.430014445563118 -1.0162484277439,-0.476964317486802 -0.982121680497641,-0.548796088081649 C-0.924223053739587,-0.67066463840585 -0.838935502109301,-0.761222544208651 -0.729895396861719,-0.81660831893169 C-0.652666116521943,-0.855835967001217 -0.614576750684788,-0.873264164823037 -0.485609042303584,-0.873977173876701 C-0.350699586517109,-0.874722734579112 -0.322299550859126,-0.858992800688447 -0.242940961547844,-0.815395523171952 C-0.146347968002977,-0.762330214620364 -0.0469265717627411,-0.648920467226447 -0.0263747757632722,-0.568359238473025 L-0.0136814424115853,-0.518601854310303 L0.0176213189786486,-0.587129243639273 C0.194511321452139,-0.974373943618093 0.75925906037766,-0.96858025176609 0.955794219395568,-0.57750443258678 C1.01814070686722,-0.453444171783601 1.02498556965361,-0.188544549947051 0.969700405654138,-0.0393279571831673 C0.897583026328065,0.155319568139341 0.762129243985689,0.303715337410879 0.449006289596482,0.531116685379815 C0.243654945277814,0.680250541777138 0.0112441103286566,0.90589356734039 -0.00493465914355834,0.937585373794258 C-0.0237153698749651,0.974373943618093 -0.00583047238947826,0.943350568269966 -0.0887761244941046,0.850401752915005 z"
),
Set Shape( "Custom" ),
Title Position( 0, 0 ),
SendToReport(
Dispatch(
{},
"1",
ScaleBox,
{Min( 50 ), Max( 72.5 ), Inc( 5 ), Minor Ticks( 1 )}
),
Dispatch(
{},
"2",
ScaleBox,
{Min( 60 ), Max( 180 ), Inc( 20 ), Minor Ticks( 0 )}
)
)
);``````
Staff

## Re: Ways to draw a heart in JMP?

``````Scatterplot 3D(
Y( :t, :x, :y ),
Frame3D(
Set Wall Color( -16735350 ),
Set Grab Handles( 0 ),
Set Rotation( -86.2748434825603, -14.3412758272124, 89.6922810282153 ),
Background Color( 255, 152, 166 )
),
SendToReport( Dispatch( {}, "3", ScaleBox, {Min( -20.1415094339623 )} ) )
);``````

And for those with Ebulliophilia (Love of Bubbles)…

``````Bubble Plot(
X( :x ),
Y( :y ),
Time( :t ),
Speed( 164.16 ),
Bubble Size( 21 ),
Time Index( 62.38 ),
Show Roles( 0 ),
Draw( "Outlined" ),
Trail Bubbles( "All" ),
Trail Lines( "All" ),
Title Position( 1.14479166666667, -17.5 ),
SendToReport(
Dispatch( {}, "1", ScaleBox, {Min( -1.25 ), Max( 1.25 ), Inc( 0.5 ), Minor Ticks( 1 )} ),
Dispatch( {}, "2", ScaleBox, {Min( -17.5 ), Max( 12.5 ), Inc( 5 ), Minor Ticks( 1 )} ),
Dispatch( {}, "Bubble Plot", FrameBox, {Frame Size( 412, 313 )} )
)
);``````

Staff

## Re: Ways to draw a heart in JMP?

Super cool!
Read the JMP Blog: jmp.com/blog
Staff

## Re: Ways to draw a heart in JMP?

My little girl wanted animated, concentric hearts after she saw Xan's (thanks for the equations, Xan!)

``````names default to here(1);

t = Index( 0, 2 * Pi(), 0.03 );
x = Power( Sin( t ), 3 );
y = 13 * Cos( t ) - 5 * Cos( 2 * t ) - 2 * Cos( 3 * t ) - Cos( 4 * t );
factors = index(.1, 1, .1);
mx = x`*factors;
my = y`*factors;

nw = new window("Hearts",
gb = graphbox(
xscale(-1.5,1.5),
yscale(-20,15),
suppressaxes

)
);

fb = gb[framebox(1)];

for(i=1, i<=nrow(mx), i++,
eval(evalexpr(
fb << Add Graphics Script(
marker(colorstate("red"),mx[expr(i),0], my[expr(i),0])
);
));
wait(.001)
);

``````

Here's a look about 75% of the way through:

Staff

## Re: Ways to draw a heart in JMP?

Lovely!
Read the JMP Blog: jmp.com/blog
Staff

## Re: Ways to draw a heart in JMP?

Since that animation worked, here's another one:

Staff

## Re: Ways to draw a heart in JMP?

Fancy!
Read the JMP Blog: jmp.com/blog
Staff

## Re: Ways to draw a heart in JMP?

If you create a column in a data table and change the data type to "expression", you can drag and drop heart images into rows. The iconarchive has many commerical free options to consider.

The column can be selected as a label and the images will show up in hover labels.

Check out the JMP blog: jmp.com/blog
Staff

## Re: Ways to draw a heart in JMP?

For those who are loopy in love...

``````dt = New Table( "Loopy Heart",
New Column( "theta", Set Values( Index( 0, 360, .01 ) ) ),
New Column( "r", Formula( 3.5 - 1.5 * Abs( cos(:theta) ) * Sqrt( 1.3 + Abs( sin( :theta) ) ) +               cos( 2 * :theta ) - 3 * sin( :theta ) + 0.7 * cos( 12.2 * :theta ) ) ),
New Column( "x", Formula( :r * cos( :theta ) ) ),
New Column( "y", Formula( :r * sin( :theta ) ) ),
New Column( "color", "rowstate", Set Formula( Color State( {206, 0, 0} ) ) )
);
dt:color << Copy To Row States();

dt << Graph Builder(
Show Control Panel( 0 ),
Variables( X( :x ), Y( :y ) ),
Elements( Points( X, Y, Legend( 9 ) ) ),
SendToReport( Dispatch( {}, "Graph Builder", FrameBox, {Marker Size( 0 )} ) )
);
``````