Git Product home page Git Product logo

easy_plot's Introduction

easy_plot

This repository gives examples for better plotting configuration in Matlab and Python. It is not a tutorial but an exhibition to show you some interesting usages when I'm working on daily figure processing. I will also give a list of references for further exploration.

Table of Contents

Quick Start (Matlab)

basic_example: how to change figure properties

There are two ways to change a figure's properties, one is to change the default settings which is a permanent approach, the other is to change the properties of the specific figure directly. If you are afraid of making a mess by changing the default settings, you may like the second one, and it is recommended to do this by calling a user-defined function by yourself if you have to configure lots of properties for each single figure, which leads to clean code styles.

  • basic_example gives you an example using the second approach to change figures' properties.

example plotting in matlabexample plotting in matlab

fig_plot: advanced figure plot example

fig_plot is an example to show how to plot figure based on csv file in a batch approach. Figure property configuration is similar to basic_example.

Parameter configuration:

  • save_enable_xx: whether to save certain figure to file or not.
  • image_path: choose the path to save your figure. The default setting is the current folder.
  • global_path_file and state_name: the path to search certain groups of files.

And it is worth noting that you can specify the color of your figure as an RGB triplet in Matlab. See how to choose color below for more recommendation to choose harmonious color.

% plot color setting
plot(time,des_delta,...
                'LineStyle','-',...
                'LineWidth',1.5,...
                'Color',[189, 189, 189] / 255,... % you can also use 'r', 'g' etc. to call for the short name of built-in colors.
                'MarkerEdgeColor','b',...
                'MarkerFaceColor','b',...
                'MarkerSize',5), hold on;

% current axis color setting
ax1 = gca;
ax1.Color = [239, 237, 245] / 255;

fig_splice: automatic figure splicing

This function can dramatically reduce our efforts to put some figures into one single figure in a batch approach. Here is an example when I am trying to compose four images into a 2x2 single image. Let's see the inputs

acceleration1steering_angle1tracking_error1velocity1

and the output:

outfigure1

You can also set the columns of the output image and whether or not cutting image edges by using the function script spliceFigureFunc.m. To see one example of how to realize this, just have a look at figure_splice.m.

Quick Start (Python)

Using Python package Matplotlib, Pandas, Numpy and other packages, you can also get similar plot, and even more convenient configuration.

basic_example: how to change figure properties

  • basic_example gives you an example using the second approach to change figures' properties.

example plotting in python

fig_plot: advanced figure plot example

fig_plot is an example to show how to plot figure based on csv file in a batch approach.

Parameter configuration:

  • save_enable: whether to save figures to file or not.
  • image_path: choose the path to save your figure. The default setting is the current folder.
  • global_path_file, search_path and filename: the path to search certain groups of files.
  • fig_dpi and figsize_inch: figure size and resolution.

And it is worth noting that you can specify the color of your figure as an RGB triplet (or hex codes) in Python. See how to choose color below for more recommendation to choose harmonious color.

Here have a look at the results:

path_comparisonacceleration2steering_angle2tracking_error2velocity2

how to choose color

There are some tools for guidance in choosing color schemes, which makes your plots more beautiful.

colorbrewer2 Adobe Color
vrep_sim_scene Adobe Color

Here is a comparison by using built-in color and color chosen from ColorBrewer2:

using built-in color using color in ColorBrewer2
using default color using color in ColorBrewer2

Dependencies

  • Python > 3.0
  • Matlab > 2014b

to-do

  • Python version
    • basic_example
    • fig_plot
    • fig_splice
  • 3D Plot
  • Contour Plot
  • Image Show

Contributing

If you have any questions or ideas to improve it, just submit issues or PRs to this repo, and I would say thanks for your contribution.

Acknowledgement

Thanks to Mr. Mie (咩先生) @科研充电宝 (one offical account on WeChat aiming at sharing various research tricks) for providing the original version of figure splicing based on which I improved and formulated the demonstration of fig_splice.

easy_plot's People

Contributors

magic-wei avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

easy_plot's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.