Matplotlib contour function modifying previous plot?

I am converting some simple octave / matlab programs to python, but when using the matplotlib function, the contourpreviously constructed 2D points seem to be aligned or smoothed at x = 1. Any ideas why this happens?

contour matplotlib

For an octave / matlab logistic regression exercise, I draw some data points

plotData(X(:,2:3), y);

and then display the border of the solution around different categories. This last part is done with contour:

contour(u, v, z, [0, 0], 'LineWidth', 2)

The result is the following:

octave / matlab correct contour result

In python, everything goes well to outline points:

p1 = plt.plot(X[pos,0], X[pos,1], marker='+', markersize=9, color='k')[0]
p2 = plt.plot(X[neg,0], X[neg,1], marker='o', markersize=7, color='y')[0]

correctly constructed data points

but when immediately after use contour, as shown below, the first image is displayed:

p3 = plt.contour(u, v, z, levels=[0], linewidth=2)

, u v /matlab python, linspace(-1, 1.5, 50) ( ). , python z python /matlab z, , .

Google , python matlab contour. !

:

, , ( ).

p1 = plt.plot(X[pos,0], X[pos,1], marker='+', markersize=9, color='k')[0]
p2 = plt.plot(X[neg,0], X[neg,1], marker='o', markersize=7, color='y')[0]

, /matlab script:

pd.plotData(X[:,1:3],y)

plotData plt.plot(...). , , ( ) , x = 1. , , !

correctly displayed data points

+4

Source: https://habr.com/ru/post/1607232/


All Articles