C++画实时散点图

strandtju 2014-04-27 12:15:14
请问怎么用C++画实时散点图?即每给出一组(x.y),就在窗口中描出一个点?
...全文
1069 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
strandtju 2014-05-01
  • 打赏
  • 举报
回复
问题解决了,只需安装easyX即可
strandtju 2014-04-30
  • 打赏
  • 举报
回复
#include<iostream> #include<math.h> #include <stdlib.h> #include <time.h> #include <stdio.h> #include <graphics.h> #include <conio.h> using namespace std; double f (double x){ return pow(cos(x),2); } void main(){ initgraph(640, 480); //初始化绘图环境,宽度为640,高度均为480 cleardevice(); setorigin(320, 0); //设置原点的物理坐标 int k(0),n; double r1,r2,s; cout<<"Please input the number of electrons:"; cin>>n; double *x=new double[n]; double *y=new double[n]; srand(time(0)); for(int i=0;i<n;i++) y[i]=rand()/double(RAND_MAX); while(k<n){ r1=rand()/double(RAND_MAX); r2=rand()/double(RAND_MAX); s=3*PI*(2*r1-1); if(r2<=f(s)){ x[k]=s; putpixel(x[n]*34,y[n]*480,WHITE); //绘制描点函数,并设缩放因子,使图像范围适合屏幕尺寸 k++; } } getch(); // 按任意键继续 closegraph(); // 关闭图形界面 } error C2065: 'setorigin' : undeclared identifier 各位大神,请问到底是哪出错了?
strandtju 2014-04-29
  • 打赏
  • 举报
回复
是啊,比如(1.22222,3.33333)
tbwork 2014-04-28
  • 打赏
  • 举报
回复
Windows画图,不能再熟,我表示听我的肯定没错。 楼主你说的实时就是速度快吧? 步骤: (1) 新建内存图片Bitmap。 (2)使用setpixel也行,使用修改图片某个内存单位的数字也行,把这些点在内存里画好。 (3) Bitblt()函数把内存图片显示到窗体上。 禁忌: 不要直接在Form上画点,速度很慢,而且会闪烁。而且一旦重绘还要画一遍。 注意点: 如果其他窗口覆盖了当前窗口,会触发重绘事件,所以需要在消息处理里,加上同样的Bitblt代码。这样快速高效。
mujiok2003 2014-04-28
  • 打赏
  • 举报
回复
看看gnuplot。
赵4老师 2014-04-28
  • 打赏
  • 举报
回复
引用 2 楼 Study_Bird 的回复:
gdi没有画点的函数,可以话实心圆
那SetPixel函数算什么函数?
Study_Bird 2014-04-28
  • 打赏
  • 举报
回复
gdi没有画点的函数,可以话实心圆
赵4老师 2014-04-28
  • 打赏
  • 举报
回复
SetPixel The SetPixel function sets the pixel at the specified coordinates to the specified color. COLORREF SetPixel( HDC hdc, // handle to device context int X, // x-coordinate of pixel int Y, // y-coordinate of pixel COLORREF crColor // pixel color ); Parameters hdc Handle to the device context. X Specifies the x-coordinate, in logical units, of the point to be set. Y Specifies the y-coordinate, in logical units, of the point to be set. crColor Specifies the color to be used to paint the point. Return Values If the function succeeds, the return value is the RGB value that the function sets the pixel to. This value may differ from the color specified by crColor; that happens when an exact match for the specified color cannot be found. If the function fails, the return value is –1. Windows NT: To get extended error information, callGetLastError. Remarks The function fails if the pixel coordinates lie outside of the current clipping region. Not all devices support the SetPixel function. For more information, see GetDeviceCaps. QuickInfo Windows NT: Requires version 3.1 or later. Windows: Requires Windows 95 or later. Windows CE: Requires version 1.0 or later. Header: Declared in wingdi.h. Import Library: Use gdi32.lib. See Also Bitmaps Overview, Bitmap Functions, GetDeviceCaps, GetPixel, SetPixelV
没事人 2014-04-28
  • 打赏
  • 举报
回复
楼主的意思是在指定的坐标上输出吧
strandtju 2014-04-28
  • 打赏
  • 举报
回复
要求坐标为double类型数据

64,639

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧