File: PlotDistance.cpp

package info (click to toggle)
ausaxs 1.1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 72,592 kB
  • sloc: cpp: 49,853; ansic: 6,901; python: 730; makefile: 18
file content (34 lines) | stat: -rw-r--r-- 1,477 bytes parent folder | download
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
// SPDX-License-Identifier: LGPL-3.0-or-later
// Author: Kristian Lytje

#include <plots/PlotDistance.h>
#include <plots/PlotDataset.h>
#include <hist/intensity_calculator/ICompositeDistanceHistogram.h>
#include <hist/distribution/Distribution1D.h>
#include <dataset/SimpleDataset.h>

using namespace ausaxs::plots;

PlotDistance::~PlotDistance() = default;

PlotDistance::PlotDistance(observer_ptr<hist::DistanceHistogram> d, const io::File& path) {
    quick_plot(d, path);
}

void PlotDistance::quick_plot(observer_ptr<hist::DistanceHistogram> d, const io::File& path) {
    const auto& distances = d->get_d_axis();
    SimpleDataset p(distances, d->get_weighted_counts());

    PlotDataset plot;
    plot.plot(p,  plots::PlotOptions("lines", {{"color", style::color::black}, {"legend", "total"}, {"xlabel", "Distance [$\\AA$]"}, {"ylabel", "Count"}}));
    if (auto cast = dynamic_cast<hist::ICompositeDistanceHistogram*>(d)) {
        SimpleDataset pp(distances, cast->get_aa_counts());
        SimpleDataset ph(distances, cast->get_aw_counts());
        SimpleDataset hh(distances, cast->get_ww_counts());

        plot.plot(pp, plots::PlotOptions("lines", {{"color", style::color::orange}, {"legend", "atom-atom"}}));
        plot.plot(ph, plots::PlotOptions("lines", {{"color", style::color::green}, {"legend", "atom-water"}}));
        plot.plot(hh, plots::PlotOptions("lines", {{"color", style::color::blue}, {"legend", "water-water"}}));
    }
    plot.save(path);
}