diff --git a/pd/src/g_template.c b/pd/src/g_template.c
index f31da70b1dc8b9bcd83bf2befd3114269fcd7043..9c3268a3e9ffb19228f6dcf148ea13e01a355051 100644
--- a/pd/src/g_template.c
+++ b/pd/src/g_template.c
@@ -5264,8 +5264,7 @@ static void plot_vis(t_gobj *z, t_glist *glist, t_glist *parentglist,
         {
             t_float xscale = glist_xtopixels(glist, 1) - glist_xtopixels(glist, 0);
             t_float yscale = glist_ytopixels(glist, 1) - glist_ytopixels(glist, 0);
-            t_float testy_y = 1 / yscale;
-//            post("testy_y is %g", testy_y);
+            t_float y_factor = 1 / yscale;
 
             symfill = (style == PLOTSTYLE_POINTS ? symoutline : symfill);
             t_float minyval = 1e20, maxyval = -1e20;
@@ -5310,7 +5309,7 @@ static void plot_vis(t_gobj *z, t_glist *glist, t_glist *parentglist,
                 {
                     int py2 = 0;
                     //int border = 0;
-                    if(style == PLOTSTYLE_POINTS)
+                    if (style == PLOTSTYLE_POINTS)
                         py2 = (int)fielddesc_cvttocoord(yfielddesc, maxyval)
                                 + linewidth - 1;
                     else
@@ -5325,7 +5324,7 @@ static void plot_vis(t_gobj *z, t_glist *glist, t_glist *parentglist,
                             int x1, y1, x2, y2;
                             graph_graphrect(&glist->gl_gobj, glist->gl_owner,
                                 &x1, &y1, &x2, &y2);
-                            py2 = y2;
+                            py2 = y2 - y1;
                             //border = 1;
                         }
                     }
@@ -5369,7 +5368,8 @@ static void plot_vis(t_gobj *z, t_glist *glist, t_glist *parentglist,
                     t_float mey1 = fielddesc_cvttocoord(yfielddesc, minyval) - 1;
 
                     int mex2 = inextx;
-                    int mey2 = py2;
+                    t_float mey2 = style == PLOTSTYLE_POINTS ?
+                        yval + y_factor * linewidth : py2 * y_factor;
                     //sys_vgui("M %d %d H %d V %d H %d z \\\n",
                     //    mex1, mey1, mex2, mey2, mex1);
 
@@ -5382,8 +5382,8 @@ static void plot_vis(t_gobj *z, t_glist *glist, t_glist *parentglist,
                     gui_i(mex2);
 
                     gui_s("V");
-                    gui_f(yval + testy_y * linewidth);
-//                    gui_i(mey2);
+//                    gui_f(yval + y_factor * linewidth);
+                    gui_f(mey2);
 
                     gui_s("H");
                     gui_i(mex1);