66 lines
2.7 KiB
C++
66 lines
2.7 KiB
C++
/********************************************************
|
|
* ██████╗ ██████╗████████╗██╗
|
|
* ██╔════╝ ██╔════╝╚══██╔══╝██║
|
|
* ██║ ███╗██║ ██║ ██║
|
|
* ██║ ██║██║ ██║ ██║
|
|
* ╚██████╔╝╚██████╗ ██║ ███████╗
|
|
* ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝
|
|
* Geophysical Computational Tools & Library (GCTL)
|
|
*
|
|
* Copyright (c) 2022 Yi Zhang (yizhang-geo@zju.edu.cn)
|
|
*
|
|
* GCTL is distributed under a dual licensing scheme. You can redistribute
|
|
* it and/or modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation, either version 2
|
|
* of the License, or (at your option) any later version. You should have
|
|
* received a copy of the GNU Lesser General Public License along with this
|
|
* program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
* If the terms and conditions of the LGPL v.2. would prevent you from using
|
|
* the GCTL, please consider the option to obtain a commercial license for a
|
|
* fee. These licenses are offered by the GCTL's original author. As a rule,
|
|
* licenses are provided "as-is", unlimited in time for a one time fee. Please
|
|
* send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget
|
|
* to include some description of your company and the realm of its activities.
|
|
* Also add information on how to contact you by electronic and paper mail.
|
|
******************************************************/
|
|
|
|
#include "../lib/graphic/gmt.h"
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
gctl::gmt gt;
|
|
/*
|
|
gt.begin_session("line_plot", "eps,png");
|
|
gt.call_module("basemap", "-R0/10/0/10 -JX5i/5i -Baf");
|
|
gt.call_module("plot", "tmp/data.txt -R0/10/0/10 -JX5i/5i -W1p,blue");
|
|
gt.end_session(false);
|
|
gt.save_session("line_plot");
|
|
*/
|
|
|
|
// example 2
|
|
gctl::array<double> data(51*41);
|
|
|
|
double dist;
|
|
for (int i = 0; i < 51; ++i)
|
|
{
|
|
for (int j = 0; j < 41; ++j)
|
|
{
|
|
dist = sqrt((j-20)*(j-20) + (i-25)*(i-25));
|
|
data[j+i*41] = sin(dist/GCTL_Pi);
|
|
}
|
|
}
|
|
|
|
gt.begin_session("image_plot", "eps");
|
|
gt.call_module("set", "FONT_ANNOT_PRIMARY=10.5p,Times-Roman,black");
|
|
|
|
std::string gname = gt.create_grid(data, 41, 51, 0.0, 1.0, 0.0, 1.0);
|
|
|
|
gt.call_module("grd2cpt", gname + " -R0/40/0/50 -Crainbow -Z -D");
|
|
gt.call_module("grdimage", gname + " -R0/40/0/50 -JX1.5i/1.5i -X0.5i -Y0.5i -Bxag+l\"x (m)\" -Byag+l\"y (m)\"");
|
|
gt.call_module("psscale", "-Bxa -By+lm -Dx0.1i/-0.2i+w1.3i/0.05i+h");
|
|
gt.end_session();
|
|
gt.save_session("image_plot");
|
|
return 0;
|
|
}
|