Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python plot

import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4], [1, 4, 9, 16])
plt.show()
Comment

how do a plot on matplotlib python

import matplotlib.pyplot as plt
%matplotlib inline
plt.plot(data)
#this is not nessisary but makes your plot more readable
plt.ylabel('y axis means ...')
plt.xlabel('x axis means ...')
Comment

how to plot in python

import matplotlib.pyplot as plt
import numpy as np

# Simple data to display in various forms
x = np.linspace(0, 2 * np.pi, 400)
y = np.sin(x ** 2)

fig, axarr = plt.subplots(2, 2)
fig.suptitle("This Main Title is Nicely Formatted", fontsize=16)

axarr[0, 0].plot(x, y)
axarr[0, 0].set_title('Axis [0,0] Subtitle')
axarr[0, 1].scatter(x, y)
axarr[0, 1].set_title('Axis [0,1] Subtitle')
axarr[1, 0].plot(x, y ** 2)
axarr[1, 0].set_title('Axis [1,0] Subtitle')
axarr[1, 1].scatter(x, y ** 2)
axarr[1, 1].set_title('Axis [1,1] Subtitle')

# Fine-tune figure;
# hide x ticks for top plots and y ticks for right plots

plt.setp([a.get_xticklabels() for a in axarr[0, :]], visible=False)
plt.setp([a.get_yticklabels() for a in axarr[:, 1]], visible=False)


# Tight layout often produces nice results
# but requires the title to be spaced accordingly

fig.tight_layout()
fig.subplots_adjust(top=0.88)

plt.show()


Comment

how to plot using matplotlib

import matplotlib
matplotlib.rc('text',usetex=True)
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle
import numpy as np

text = 'egin{tabular}{|c|c|}hline1&2\hline3&4\hlineend{tabular}'

fig, ax = plt.subplots(1)

img = ax.imshow(np.zeros((10,10)), cmap=plt.cm.gray)
txt = ax.text( 4.5,
          4.5,
          text,
          fontsize=24,
          ha='center',
          va='center',
          bbox=dict(alpha=0))

fig.canvas.draw()
bbox = txt.get_bbox_patch()
xmin = bbox.get_window_extent().xmin
xmax = bbox.get_window_extent().xmax
ymin = bbox.get_window_extent().ymin
ymax = bbox.get_window_extent().ymax

xmin, ymin = fig.transFigure.inverted().transform((xmin, ymin))
xmax, ymax = fig.transFigure.inverted().transform((xmax, ymax))

dx = xmax-xmin
dy = ymax-ymin

# The bounding box vals can be tweaked manually here.
rect = Rectangle((xmin-0.02,ymin-0.01), dx+0.04, dy+0.05, fc='w', transform=fig.transFigure)

ax.add_patch(rect)
fig.canvas.draw()
ax.axis('off')
plt.savefig('ok.png',bbox_inches='tight')




Comment

PREVIOUS NEXT
Code Example
Python :: how to hide ticks marks in plot 
Python :: iterating index array python 
Python :: python gzip a file 
Python :: sklearn random forest 
Python :: create a date list in postgresql 
Python :: tkinter include svg in script 
Python :: pandas read csv without scientific notation 
Python :: map function in python 
Python :: python re.search() 
Python :: raspi setup gpio 
Python :: lambda and function in python 
Python :: url_for 
Python :: discord.py message user 
Python :: python chat 
Python :: how to install django 
Python :: swap in python 
Python :: how to set the value of a variable null in python 
Python :: axios django csrf 
Python :: python sort multiple keys 
Python :: box plot python 
Python :: Add PostgreSQL Settings in Django 
Python :: lable on graph in matplotlib 
Python :: empty list in python 
Python :: how to split string by list of indexes python 
Python :: create new list with for loop python 
Python :: python random number generator no duplicates 
Python :: Python Tkinter PanedWindow Widget 
Python :: bar plot python 
Python :: How do I stop Selenium from closing my browser 
Python :: Word2Vec 4.0 Gensim model python dataframe 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =