Skip to content
Snippets Groups Projects
Commit df1414be authored by soblin's avatar soblin
Browse files

added scales/aspect_loglog

parent c2dd7040
No related branches found
No related tags found
No related merge requests found
......@@ -35,10 +35,11 @@ endif()
# gallery
if(NOT DEFINED USE_GUI)
set(USE_GUI 1)
message(STATUS "USE_GUI = ON")
message(STATUS "set USE_GUI = ON")
endif()
if(NOT DEFINED ADD_DEMO)
set(ADD_DEMO 1)
message(STATUS "set ADD_DEMO = ON")
endif()
if(USE_GUI)
message(STATUS "USE_GUI = ON")
......@@ -77,6 +78,7 @@ if(${ADD_DEMO})
add_subdirectory(gallery/shapes_and_collections)
add_subdirectory(gallery/artist_animation)
add_subdirectory(gallery/mplot3d)
add_subdirectory(gallery/scales)
endif()
# test
......
add_demo(aspect_loglog aspect_loglog.cpp)
add_custom_target(scales
DEPENDS aspect_loglog
COMMAND aspect_loglog
COMMENT "running scales"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../images"
)
// example from https://matplotlib.org/stable/gallery/scales/aspect_loglog.html
#include <matplotlibcpp17/pyplot.h>
#include <matplotlibcpp17/animation.h>
#include <vector>
using namespace std;
using namespace matplotlibcpp17;
int main() {
py::scoped_interpreter guard{};
auto plt = pyplot::import();
auto [fig, axs] = plt.subplots(1, 2);
auto &ax1 = axs[0], ax2 = axs[1];
ax1.set_xscale(Args("log"));
ax1.set_yscale(Args("log"));
ax1.set_xlim(Args(1e+1, 1e+3));
ax1.set_ylim(Args(1e+2, 1e+3));
ax1.set_aspect(Args(1));
ax1.set_title(Args("adjustable = box"));
ax2.set_xscale(Args("log"));
ax2.set_yscale(Args("log"));
ax2.set_adjustable(Args("datalim"));
ax2.plot(Args(vector<int>({1, 3, 10}), vector<int>({1, 9, 100}), "o-"));
ax2.set_xlim(Args(1e-1, 1e+2));
ax2.set_ylim(Args(1e-1, 1e+3));
ax2.set_aspect(Args(1));
ax2.set_title(Args("adjustable = datalim"));
plt.show();
}
......@@ -159,6 +159,11 @@ public:
pybind11::object set(const pybind11::tuple &args = pybind11::tuple(),
const pybind11::dict &kwargs = pybind11::dict());
// set_adjustable
pybind11::object
set_adjustable(const pybind11::tuple &args = pybind11::tuple(),
const pybind11::dict &kwargs = pybind11::dict());
// set_aspect
pybind11::object set_aspect(const pybind11::tuple &args = pybind11::tuple(),
const pybind11::dict &kwargs = pybind11::dict());
......@@ -175,6 +180,10 @@ public:
pybind11::object set_xlim(const pybind11::tuple &args = pybind11::tuple(),
const pybind11::dict &kwargs = pybind11::dict());
// set_xscale
pybind11::object set_xscale(const pybind11::tuple &args = pybind11::tuple(),
const pybind11::dict &kwargs = pybind11::dict());
// set_xticks
pybind11::object set_xticks(const pybind11::tuple &args = pybind11::tuple(),
const pybind11::dict &kwargs = pybind11::dict());
......@@ -192,6 +201,10 @@ public:
pybind11::object set_ylim(const pybind11::tuple &args = pybind11::tuple(),
const pybind11::dict &kwargs = pybind11::dict());
// set_yscale
pybind11::object set_yscale(const pybind11::tuple &args = pybind11::tuple(),
const pybind11::dict &kwargs = pybind11::dict());
// set_yticks
pybind11::object set_yticks(const pybind11::tuple &args = pybind11::tuple(),
const pybind11::dict &kwargs = pybind11::dict());
......@@ -256,14 +269,17 @@ private:
LOAD_FUNC_ATTR(quiverkey, self);
LOAD_FUNC_ATTR(scatter, self);
LOAD_FUNC_ATTR(set, self);
LOAD_FUNC_ATTR(set_adjustable, self);
LOAD_FUNC_ATTR(set_aspect, self);
LOAD_FUNC_ATTR(set_title, self);
LOAD_FUNC_ATTR(set_xlabel, self);
LOAD_FUNC_ATTR(set_xlim, self);
LOAD_FUNC_ATTR(set_xscale, self);
LOAD_FUNC_ATTR(set_xticks, self);
LOAD_FUNC_ATTR(set_xticklabels, self);
LOAD_FUNC_ATTR(set_ylabel, self);
LOAD_FUNC_ATTR(set_ylim, self);
LOAD_FUNC_ATTR(set_yscale, self);
LOAD_FUNC_ATTR(set_yticks, self);
LOAD_FUNC_ATTR(text, self);
LOAD_FUNC_ATTR(tick_params, self);
......@@ -297,14 +313,17 @@ private:
pybind11::object quiverkey_attr;
pybind11::object scatter_attr;
pybind11::object set_attr;
pybind11::object set_adjustable_attr;
pybind11::object set_aspect_attr;
pybind11::object set_title_attr;
pybind11::object set_xlabel_attr;
pybind11::object set_xlim_attr;
pybind11::object set_xscale_attr;
pybind11::object set_xticks_attr;
pybind11::object set_xticklabels_attr;
pybind11::object set_ylabel_attr;
pybind11::object set_ylim_attr;
pybind11::object set_yscale_attr;
pybind11::object set_yticks_attr;
pybind11::object set_zlabel_attr;
pybind11::object set_zlim_attr;
......@@ -547,6 +566,13 @@ pybind11::object Axes::set(const pybind11::tuple &args,
return ret;
}
// set_adjustable
pybind11::object Axes::set_adjustable(const pybind11::tuple &args,
const pybind11::dict &kwargs) {
pybind11::object ret = set_adjustable_attr(*args, **kwargs);
return ret;
}
// set_aspect
pybind11::object Axes::set_aspect(const pybind11::tuple &args,
const pybind11::dict &kwargs) {
......@@ -575,6 +601,13 @@ pybind11::object Axes::set_xlim(const pybind11::tuple &args,
return ret;
}
// set_xscale
pybind11::object Axes::set_xscale(const pybind11::tuple &args,
const pybind11::dict &kwargs) {
pybind11::object ret = set_xscale_attr(*args, **kwargs);
return ret;
}
// set_xticks
pybind11::object Axes::set_xticks(const pybind11::tuple &args,
const pybind11::dict &kwargs) {
......@@ -603,6 +636,13 @@ pybind11::object Axes::set_ylim(const pybind11::tuple &args,
return ret;
}
// set_yscale
pybind11::object Axes::set_yscale(const pybind11::tuple &args,
const pybind11::dict &kwargs) {
pybind11::object ret = set_yscale_attr(*args, **kwargs);
return ret;
}
// set_yticks
pybind11::object Axes::set_yticks(const pybind11::tuple &args,
const pybind11::dict &kwargs) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment