-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10_setting_graph.cpp
More file actions
43 lines (36 loc) · 1.68 KB
/
Copy path10_setting_graph.cpp
File metadata and controls
43 lines (36 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "qcustomplot.h"
#include <QDebug>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QDesktopWidget>
#endif
#include <QScreen>
#include <QMessageBox>
#include <QMetaEnum>
#include <cmath>
void setting_labels(QCustomPlot *customPlot){
// 軸ラベルの設定
// x軸編集
customPlot->xAxis->setLabel("x");
customPlot->xAxis->setLabelFont(QFont(QFont().family(), 25));
customPlot->xAxis->setRange(0.0, 10.1); // x軸範囲
customPlot->xAxis->setTickLabelFont(QFont(QFont().family(), 25));
// y軸編集
customPlot->yAxis->setLabel("y");
customPlot->yAxis->setLabelFont(QFont(QFont().family(), 25));
customPlot->yAxis->setRange(0, 105); // y軸範囲
customPlot->yAxis->setTickLabelFont(QFont(QFont().family(), 25));
customPlot->axisRect()->setupFullAxesBox(); // グラフ枠線
}
// 凡例の出力
void setting_legend(QCustomPlot *customPlot){
customPlot->legend->setVisible(true); // ここで凡例を表示するかを選択する。
QFont legendFont = QToolTip::font();
legendFont.setPointSize(12); // 凡例のフォントサイズ
customPlot->legend->setFont(legendFont);
customPlot->legend->setBrush(QBrush(QColor(255, 255, 255, 230)));
customPlot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignTop|Qt::AlignRight); // 凡例の場所位置を決めるところ
}
void setting_save_files(QCustomPlot *customPlot){
QString fileName = "graph_plot.png";
customPlot->savePng(fileName, 800, 500, 1.0, -1);
}