Last active
October 31, 2020 13:52
-
-
Save imvickykumar999/9c82a433a1e19d1e6034807f4fcf1ddb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/imvickykumar999/vixtor/blob/master/Subplot.ipynb | |
import numpy as np, math | |
import matplotlib.pyplot as plt | |
def subplot( | |
l1=False, a1=[1,0,1], b1=[4,9,4], | |
ul1=30, colorl1='blue', two_pointsl1=False, | |
l2=False, a2=[-1,9,2], b2=[2,4,7], | |
ul2=30, colorl2='black', two_pointsl2=False, | |
p1=False, n1=[3,-6,2], d1=7, up1=100, colorp1='green', | |
p2=False, n2=[2,1,-2], d2=5, up2=100, colorp2='red' | |
): | |
a1 = np.array(a1) | |
if two_pointsl1 == True: | |
b1 = b1-a1 | |
else: | |
b1 = np.array(b1) | |
b1 = a1 + ul1*b1 | |
a2 = np.array(a2) | |
if two_pointsl2 == True: | |
b2 = b2-a2 | |
else: | |
b2 = np.array(b2) | |
b2 = a2 + ul2*b2 | |
n1 = np.array(n1) | |
n2 = np.array(n2) | |
X, Y = np.meshgrid(range(up1), range(up1)) | |
Z1 = (-n1[0] * X - n1[1] * Y - d1)/n1[2] | |
Z2 = (-n2[0] * X - n2[1] * Y - d2)/n2[2] | |
fig = plt.figure() | |
ax = fig.add_subplot(111, projection='3d') | |
if l1: | |
ax.plot(xs=[a1[0], b1[0]], ys=[a1[1], b1[1]], | |
zs=[a1[2], b1[2]], color=colorl1) | |
if l2: | |
ax.plot(xs=[a2[0], b2[0]], ys=[a2[1], b2[1]], | |
zs=[a2[2], b2[2]], color=colorl2) | |
if p1: | |
ax.plot_surface(X, Y, Z1, color=colorp1, alpha=.7) | |
if p2: | |
ax.plot_surface(X, Y, Z2, color=colorp2, alpha=.7) | |
plt.show() | |
subplot( # this is function call, just comment the line, which not to plot... | |
l1=True, a1=[1,0,1], b1=[4,9,4], ul1=30, colorl1='blue', two_pointsl1=False, | |
l2=True, a2=[-1,9,2], b2=[2,4,7], ul2=30, colorl2='black', two_pointsl2=False, | |
p1=True, n1=[3,-6,2], d1=7, up1=100, colorp1='green', | |
p2=True, n2=[2,1,-2], d2=5, up2=100, colorp2='red' | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment