怎么用python绘图

2024-05-03 23:33

1. 怎么用python绘图

你可以使用numpy和matplotlab这两个库来实现的你功能。
你的图可以参考:
http://matplotlib.org/examples/pylab_examples/histogram_percent_demo.html
import matplotlibfrom numpy.random import randnimport matplotlib.pyplot as pltfrom matplotlib.ticker import FuncFormatterdef to_percent(y, position):    # Ignore the passed in position. This has the effect of scaling the default    # tick locations.    s = str(100 * y)    # The percent symbol needs escaping in latex    if matplotlib.rcParams['text.usetex'] == True:        return s + r'$\%$'    else:        return s + '%'x = randn(5000)# Make a normed histogram. It'll be multiplied by 100 later.plt.hist(x, bins=50, normed=True)# Create the formatter using the function to_percent. This multiplies all the# default labels by 100, making them all percentagesformatter = FuncFormatter(to_percent)# Set the formatterplt.gca().yaxis.set_major_formatter(formatter)plt.show()
最主要的就是x轴和y轴的处理,我按照对数算了一下你提供的数据,好像和这个图效果不一样。

如果解决了您的问题请采纳!如果未解决请继续追问

怎么用python绘图

2. python怎么在屏幕上画图

首先说你的要求有些不明确的部分
比如说你在所有窗体上写
那是否画图的同时还要拖动其他窗体?
这个要求的话
目前的python各种gui库貌似还没有支持到这么个绘画不规则窗体而不会挡住其他窗体还又在其上的;

如果只是在他们上面你可以画图而不用一定要拖动其他窗体的话
可以设计窗体为全屏大小,背景透明,不显示标题栏,然后用普通的画图函数就可以了 
对了
推荐使用wxpython

3. python怎么用列表中的数据画图

可以在matplotlib的文档中找到各种图表类型,由于根据特定布局创建Figure和subplot是一件常见的任务,于是便出现一个更为方便的方法:
plt.subplots,它可以创建一个新的Figure,且返回一个含有已创建的subplot对象的numpy数组。

python怎么用列表中的数据画图

4. 怎样用python对csv的一行数据进行画图。

不知道你的一行数据是怎样的,或者说想画什么图。如果说一行数据都是数字,你可以用matplotlib去画,一般画图都需要x轴y轴两种,你可以把你的那一行数据作为y轴,x轴用0到n  ,n是数据长度。

5. 怎么用python实现鼠标绘图

import win32api
import win32gui
import win32con
import time
import ctypes

def click1(x,y):                #第一种
win32api.SetCursorPos((x,y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)

def click2(x,y):               #第二种
ctypes.windll.user32.SetCursorPos(x,y)
ctypes.windll.user32.mouse_event(2,0,0,0,0)
ctypes.windll.user32.mouse_event(4,0,0,0,0)

def click_it(pos):          #第三种
handle= win32gui.WindowFromPoint(pos)
client_pos =win32gui.ScreenToClient(handle,pos)
tmp=win32api.MAKELONG(client_pos[0],client_pos[1])
win32gui.SendMessage(handle, win32con.WM_ACTIVATE,win32con.WA_ACTIVE,0)
win32gui.SendMessage(handle, win32con.WM_LBUTTONDOWN,win32con.MK_LBUTTON,tmp)
win32gui.SendMessage(handle, win32con.WM_LBUTTONUP,win32con.MK_LBUTTON,tmp)

怎么用python实现鼠标绘图

6. 怎样用python画对数图

1、用python画出log1.5(x),log(2x),log(3x)
[python] view plain copy
import numpy as np  
import math  
import matplotlib.pyplot as plt  
x=np.arange(0.05,3,0.05)  
y1=[math.log(a,1.5)for a in x]  
y2=[math.log(a,2)for a in x]  
y3=[math.log(a,3)for a in x]  
plot1=plt.plot(x,y1,'-g',label="log1.5(x)")  
plot2=plt.plot(x,y2,'-r',label="log2(x)")  
plot3=plt.plot(x,y3,'-b',label="log3(x)")  
plt.legend(loc='lower right')  
plt.show()  
2、输出结果

7. 怎么用python opencv连线画图?

import cv2
import numpy as np
 
img_size = (210,210)
image = np.ones(img_size) * 255
 
x1 = 10
y1 =10
x2 = 200
y2 = 200
 
 
lineThickness = 2
cv2.line(image, (x1, y1), (x1, y2), (0,255,0), lineThickness)
cv2.line(image, (x1, y1), (x2, y1), (0,255,0), lineThickness)
cv2.line(image, (x1, y2), (x2, y2), (0,255,0), lineThickness)
cv2.line(image, (x2, y1), (x2, y2), (0,255,0), lineThickness)
 
 
cv2.imshow('oo',image)
cv2.waitKey()

怎么用python opencv连线画图?

8. 利用python画图的优势在什么地方

相对于C和java来说画图要方便很多,且美观,几行代码就可以画出不错的图表。
(相对而言,我觉得还是Matlab画图比python更方便一点点,两者很相似)
最新文章
热门文章
推荐阅读