python - Is there a built-in method to plot symmetric functions? -


i'm plotting symmetric function (odd/even), have like:

plt.plot(np.concatenate([-x[::-1],x]),np.concatenate([y[::-1],y])) 

is there easier way this, have waste less memory?

why not plot 2 lines:

def plot_odd(x,y, *args, **kwargs):     plt.plot(x,y,*args,**kwargs)     plt.plot(-x[::-1], -y[::-1], *args, **kwargs)  def plot_even(x,y, *args, **kwargs):     plt.plot(x,y,*args,**kwargs)     plt.plot(-x[::-1], y[::-1], *args, **kwargs)  x = np.linspace(0,6,100) plot_odd(x, np.sin(x), 'b') plot_even(x, np.cos(x), 'r') plt.show() 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -