首页 > 其他分享 > qcustomplot 绘图 1

 qcustomplot 绘图 1

时间:2023-06-17 11:46:24浏览次数:29  
标签:plot set CMAKE qcustomplot VERSION 绘图 layout

周末,闲读,翻翻qcustomplot 例子。

以前用qchart, 实在无法接收这个类的低效。打开qchart, 仿佛在推一个滞重的铁门。qcustomplot 感觉轻快灵动。

1. 准备CMakeLists.txt

cmake_minimum_required(VERSION 3.5)

project(plot_0 VERSION 0.1 LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets PrintSupport)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets PrintSupport)

set(PROJECT_SOURCES
        main.cpp
        window.cpp
        window.h
        ../plot/qcustomplot.h
        ../plot/qcustomplot.cpp
)

qt_add_executable(plot_0
    MANUAL_FINALIZATION
    ${PROJECT_SOURCES}
)

target_link_libraries(plot_0 PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport)

set_target_properties(plot_0 PROPERTIES
    WIN32_EXECUTABLE TRUE
)

install(TARGETS plot_0
    BUNDLE DESTINATION .
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

 

绘制一个基本图:

   QWidget *w = new QWidget;
   QCustomPlot *plot = new QCustomPlot(w);
   ... 
   //设置窗口显示,属于qt 日常操作
   QVBoxLayout *layout = new QVBoxLayout(w);
   layout->setSpacing(6);
   layout->setContentsMargins(11, 11, 11, 11);
   layout->addWidget(plot);
   ...

    plot->addGraph();
    plot->graph(0)->setData(x, y);

    plot->xAxis->setLabel("x");
    plot->yAxis->setLabel("y");

    plot->xAxis->setRange(-1, 1);
    plot->yAxis->setRange(0, 1);

 

标签:plot,set,CMAKE,qcustomplot,VERSION,绘图,layout
From: https://www.cnblogs.com/kingkaixuan/p/17487267.html

相关文章

  • qcustomplot 绘图 2
    这个例子涉及:双坐标,坐标联动、坐标自适应、多线绘制,图形填充,图形缩放plot->addGraph();plot->graph(0)->setPen(QPen(Qt::blue));//linecolorblueforfirstgraphplot->graph(0)->setBrush(QBrush(QColor(0,0,255,20)));//firstgraphwillbefilledw......
  • Altair绘图自学成材
    目录1。Altair介绍(全名:Vega-Altair)2。一步一步学画图3。样例一个用自定义图标显示在坐标轴里的图形1。Altair介绍(全名:Vega-Altair)它是一个专为Python编写的可视化软件包,它能让数据科学家更多地关注数据本身和其内在的联系。https://github.com/altair-viz/altair安装:Vega-Alta......
  • 实验6 turtle绘图与python库应用编程体验
    实验任务1fromturtleimport*defmove(x,y):'''画笔移动到坐标(x,y)处'''penup()goto(x,y)pendown()defdraw(n,size=100):'''绘制边长为size的正n边形'''foriinrange(n):fd(siz......
  • Python 绘图 colorbar 隐藏刻度保留标签 (颜色刻度 和标签刻度 两个)
      ax3=fig.add_axes(config['setpng']['colorbar'])#四个参数分别是左、下、宽、长  cb3=mpl.colorbar.ColorbarBase(ax3,cmap=_cmap,norm=norm)  #set_colorbar_ticks(cb3,levels,config['levels']['wind_s_label'])#色标刻度调整  ......
  • 实验6 turtle绘图与python库应用编程体验
    实验任务1task1-11fromturtleimport*2defmove(x,y):3penup()4goto(x,y)5pendown()6defdraw(n,size=100):7foriinrange(n):8fd(size)9left(360/n)10defmain():11pensize(2)12pencolor(......
  • 实验6 turtle绘图与python库应用编程体验
    task1-1源代码1fromturtleimport*23defmove(x,y):4'''画笔移动到坐标(x,y)处'''5penup()6goto(x,y)7pendown()89defdraw(n,size=100):10'''绘制边长为size的正n变形'''1......
  • 实验6 turtle绘图与Python库应用编程体验
    task1-1.py实验源码:fromturtleimport*defmove(x,y):penup()goto(x,y)pendown()defdraw(n,size=100):foriinrange(n):fd(size)left(360/n)defmain():pensize(2)pencolor('red')move(-200,0)......
  • 实验6 turtle绘图与python库应用编程体验
    task1_1代码:fromturtleimport*defmove(x,y):'''画笔移动到坐标(x,y)处'''penup()goto(x,y)pendown()defdraw(n,size=100):'''绘制边长为size的正n变形'''foriinrange(n):......
  • 实验6 turtle绘图与python库应用编程体验
    实验任务1task1_1.py程序源码:1fromturtleimport*23defmove(x,y):#画笔移动到坐标(x,y)处4penup()5goto(x,y)6pendown()78defdraw(n,size=100):#绘制边长为size的正n变形9foriinrange(n):10forward(size)11......
  • 实验六 turtle绘图与python库应用编程体验
    1fromturtleimport*234defmove(x,y):5penup()6goto(x,y)7pendown()8910defdraw(n,size=100):11foriinrange(n):12fd(size)13left(360/n)141516defmain():17pensize(2)18pen......