{"id":46620,"date":"2020-11-13T00:00:00","date_gmt":"2020-11-13T08:00:00","guid":{"rendered":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/blog\/data-visualization-with-python-matplotlib-and-griddb\/"},"modified":"2025-11-13T12:55:03","modified_gmt":"2025-11-13T20:55:03","slug":"data-visualization-with-python-matplotlib-and-griddb","status":"publish","type":"post","link":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/","title":{"rendered":"Data Visualization with Python Matplotlib and GridDB"},"content":{"rendered":"<h2> Introduction <\/h2>\n<p>Data is general is a large heap of numbers, to a non-expert these numbers may be more confusing than they are informative. With the advent of big data, even experts have a difficult time making sense of data. This is where visualization comes in. Data visualization can be thought of as the graphical representation of information. Visual elements like charts, graphs and maps are often key to understanding trends in data and making data driven decisions. A good visualization is often the best way to communicate results , after all, \u00e2\u20ac\u0153a picture is worth a thousand words\u00e2\u20ac\u009d. In this post we will look into some key elements of visualization using python and GridDB.<\/p>\n<p><a href=\"#source-code\"> FULL SOURCE CODE <\/a><\/p>\n<p>Before we can get into visualization, it is important to have a database that can handle big data easily. This is where GridDB comes in. GridDB is an open source time series database optimized for IoT and Big Data. GridDB is high, scalable, reliable, ensures high performance and is optimised for IoT. Moreover, GridDB is easy to use with a number of popular programming languages like C, python and java. Installation is pretty simple, and is well documented <a href=\"https:\/\/docs.griddb.net\/gettingstarted\/python\/\">here<\/a>. To checkout the python-gridDB client please refer to <a href=\"https:\/\/www.youtube.com\/watch?v=yWCVfLoV9_0&amp;t=61s\">this video<\/a>. <\/p>\n<p>In this post we will create a few simple visualizations using the matplotlib library in python. <\/p>\n<h2 id=\"setup\">Setup<\/h2>\n<h3 id=\"quick-setup-of-griddb-python-client-on-ubuntu-20-04-\">Quick setup of GridDB Python Client on Ubuntu 20.04:<\/h3>\n<p>    1. Install GridDB<br \/>\n      Download and install the deb from <a href=\"https:\/\/griddb.net\/en\/downloads\/\">here<\/a>.<\/p>\n<p>    2. Install C client<br \/>\n      Download and install the Ubuntu from <a\n        href=\"https:\/\/software.opensuse.org\/download\/package?project=home:knonomura&amp;package=griddb-c-client\">here<\/a>.<\/p>\n<p>    3. Install requirements<br \/>\n      A) Swig<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"lang-bash\">wget https:\/\/prdownloads.sourceforge.net\/swig\/swig-3.0.12.tar.gz\ntar xvfz swig-3.0.12.tar.gz\ncd swig-3.0.12\n.\/configure\nmake \nsudo make install<\/code><\/pre>\n<\/div>\n<p>    B) Pcre<\/p>\n<\/ol>\n<div class=\"clipboard\">\n<pre><code class=\"lang-bash\">sudo apt-get install -y libpcre2-dev <\/code><\/pre>\n<\/div>\n<p>C) Install python client<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"lang-bash\">wget \nhttps:\/\/github.com\/griddb\/python_client\/archive\/0.8.1.tar.gz\n\ntar xvzf 0.8.1.tar.gz\n<\/code><\/pre>\n<\/div>\n<p>Make sure you have python-dev installed for the corresponding python version. If you are using python 3.6 then you<br \/>\n  may need to add the repository first<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"lang-bash\">sudo add-apt-repository ppa:deadsnakes\/ppa <\/code><\/pre>\n<\/div>\n<p>Then<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"lang-bash\">sudo apt-<span class=\"hljs-built_in\">get<\/span> install python3<span class=\"hljs-number\">.6<\/span>-<span class=\"hljs-built_in\">dev<\/span>\n<\/code><\/pre>\n<\/div>\n<p>Installing the python-client<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"lang-bash\">cd python_client<span class=\"hljs-number\">-0.8<\/span><span class=\"hljs-number\">.1<\/span>\/\nmake\n<\/code><\/pre>\n<\/div>\n<p>We also need to point to the correct locations<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"lang-bash\">export LIBRARY_PATH=<span class=\"hljs-variable\">$LIBRARY_PATH<\/span><span class=\"hljs-symbol\">:\/usr\/share\/doc\/griddb-c-client<\/span> [insert path to c_client]\nexport  PYTHONPATH=<span class=\"hljs-variable\">$PYTHONPATH<\/span><span class=\"hljs-symbol\">:<\/span>[insert path to python_client]\nexport LIBRARY_PATH=<span class=\"hljs-variable\">$LD_LIBRARY_PATH<\/span><span class=\"hljs-symbol\">:<\/span>[insert path to c_client\/bin]\n<\/code><\/pre>\n<\/div>\n<h3 id=\"python-libraries\">Python libraries<\/h3>\n<p>We will use python 3.6 for this post. Installing matplotlib, numpy, statsmodel and pandas is a simple pip install.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"lang-bash\">pip <span class=\"hljs-keyword\">install<\/span> matplotlib\npip <span class=\"hljs-keyword\">install<\/span> numpy\npip <span class=\"hljs-keyword\">install<\/span> pandas\npip <span class=\"hljs-keyword\">install<\/span> statsmodels\n<\/code><\/pre>\n<\/div>\n<p>Now we can get to the visualization .<\/p>\n<p>GridDB provides a nice interface to access time series data. We can simply connect to a GridDB cluster and then dump all the data to a pandas dataframe. <a href=\"https:\/\/griddb.net\/en\/blog\/python-client\/\">This post<\/a> goes into the details of how to access data from a GridDB cluster using python. For a quick reference, we can simply declare a GridDB cluster and perform sql queries on it. For example,<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"lang-python\">query = ts.query(\"<span class=\"hljs-keyword\">select<\/span> * <span class=\"hljs-keyword\">where<\/span> <span class=\"hljs-keyword\">timestamp<\/span> &gt; <span class=\"hljs-keyword\">TIMESTAMPADD<\/span>(<span class=\"hljs-keyword\">HOUR<\/span>, <span class=\"hljs-keyword\">NOW<\/span>(), <span class=\"hljs-number\">-6<\/span>)<span class=\"hljs-string\">\")<\/span>\n<\/code><\/pre>\n<\/div>\n<h2 id=\"data-analysis-and-visualisation\">Data Analysis and Visualization <\/h2>\n<h3 id=\"step-1-downloading-dataset\">Step 1: Downloading Dataset<\/h3>\n<p>We will use a publicly available dataset from Kaggle. For this post we have picked the <a\n    href=\"https:\/\/www.kaggle.com\/shenba\/time-series-datasets?select=sales-of-shampoo-over-a-three-ye.csv\">shampoo sales data<\/a>. This dataset contains sales of shampoo over a three year period at the month level. Thus, the two columns in this dataset are sales and month-year.<\/p>\n<h3 id=\"step-2-importing-libraries\">Step 2: Importing Libraries<\/h3>\n<p> We first import relevant libraries i.e pandas for loading the dataset, matplotlib for visualizations and statsmodel for some time series analysis. The plot object in matplotlib is called pylot which we import as plt. We will talk about the time series import in more detail later in the post. <\/p>\n<div class=\"clipboard\">\n<pre><code class=\"lang-python\"><span class=\"hljs-keyword\">import<\/span> pandas <span class=\"hljs-keyword\">as<\/span> pd\n<span class=\"hljs-title\">from<\/span> matplotlib <span class=\"hljs-keyword\">import<\/span> pyplot <span class=\"hljs-keyword\">as<\/span> plt\n<span class=\"hljs-title\">from<\/span> statsmodels.tsa.seasonal <span class=\"hljs-keyword\">import<\/span> seasonal_decompose\n<\/code><\/pre>\n<\/div>\n<h3 id=\"step-3-data-loading-and-processing\">Step 3: Data Loading and Processing<\/h3>\n<p>First we load the data. For this we use the read_csv functionality in pandas.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"lang-python\"><span class=\"hljs-attr\">df<\/span> = pd.read_csv(<span class=\"hljs-string\">\"sales-of-shampoo-over-a-three-ye.csv\"<\/span>)\n<\/code><\/pre>\n<\/div>\n<p>Alternatively, we can use GridDB to get this dataframe.<\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2020\/11\/image8.png\" alt=\"\" width=\"347\" height=\"294\"\n  class=\"aligncenter size-full wp-image-27009\" srcset=\"\/wp-content\/uploads\/2020\/11\/image8.png 347w, \/wp-content\/uploads\/2020\/11\/image8-300x254.png 300w\" sizes=\"(max-width: 347px) 100vw, 347px\" \/><\/p>\n<p>The data has two columns \u00e2\u20ac\u0153Month\u00e2\u20ac\u009d and \u00e2\u20ac\u0153Sales of shampoo over a three year period\u00e2\u20ac\u009d.<\/p>\n<p>Next we split the Month column which has the format year-month column into two columns year and month. <\/p>\n<div class=\"clipboard\">\n<pre><code class=\"lang-python\">df[[<span class=\"hljs-string\">'year'<\/span>,<span class=\"hljs-string\">'month'<\/span>]] = df<span class=\"hljs-selector-class\">.Month<\/span><span class=\"hljs-selector-class\">.str<\/span><span class=\"hljs-selector-class\">.split<\/span>(<span class=\"hljs-string\">\"-\"<\/span>,expand=True)\n<\/code><\/pre>\n<\/div>\n<p>Now we can move on to the visualizations. <\/p>\n<h3 id=\"step-4-visualisations\">Step 4: Visualization<\/h3>\n<h4 id=\"line-plot\">Line Plot<\/h4>\n<p>First we use a simple line plot with year-month on the x axis and sales on the y axis. The figsize determines the size of the figure, line style determines the type of line we use, markers tells us which marker to use (s for squares). The colors for the line and markers can be set using the colour and markerfacecolor option respectively and the size of the marker can be set with markersize. Furthermore we rename the labels of the plot. More references to the various arguments that can be passed to plot can be found <a href=\"https:\/\/matplotlib.org\/3.1.1\/tutorials\/introductory\/pyplot.html\">here<\/a>.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"lang-python\"><span class=\"hljs-selector-tag\">df<\/span><span class=\"hljs-selector-class\">.plot<\/span>(x=<span class=\"hljs-string\">'Month'<\/span>,y=<span class=\"hljs-string\">'Sales of shampoo over a three year period'<\/span>,figsize=(<span class=\"hljs-number\">15<\/span>,<span class=\"hljs-number\">6<\/span>),linestyle=<span class=\"hljs-string\">'-'<\/span>, marker=<span class=\"hljs-string\">'s'<\/span>, markerfacecolor=<span class=\"hljs-string\">'b'<\/span>,color=<span class=\"hljs-string\">'y'<\/span>,markersize=<span class=\"hljs-number\">11<\/span>)\n<span class=\"hljs-selector-tag\">plt<\/span><span class=\"hljs-selector-class\">.xlabel<\/span>(<span class=\"hljs-string\">'Year-Month'<\/span>)\n<span class=\"hljs-selector-tag\">plt<\/span><span class=\"hljs-selector-class\">.ylabel<\/span>(<span class=\"hljs-string\">'Sales'<\/span>)\n<\/code><\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2020\/11\/image5.png\" alt=\"\" width=\"891\" height=\"371\"\n  class=\"aligncenter size-full wp-image-27010\" srcset=\"\/wp-content\/uploads\/2020\/11\/image5.png 891w, \/wp-content\/uploads\/2020\/11\/image5-300x125.png 300w, \/wp-content\/uploads\/2020\/11\/image5-768x320.png 768w, \/wp-content\/uploads\/2020\/11\/image5-600x250.png 600w\" sizes=\"(max-width: 891px) 100vw, 891px\" \/><\/p>\n<p>We can see that there is a year over year increase in shampoo sales, so there is a clear increasing trend in the data. We also note that the highest sales in each year are consistently around November. This indicates there is some seasonality in the datasets well. <\/p>\n<p>Next we average the data over a month and see the trend.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"lang-python\">dfm =df.groupby(<span class=\"hljs-string\">'month'<\/span>).mean().reset_index().sort_values(by=[<span class=\"hljs-string\">'month'<\/span>])\ndfm[<span class=\"hljs-string\">\"month_number\"<\/span>] = pd.to_datetime(dfm[<span class=\"hljs-string\">\"month\"<\/span>], format= <span class=\"hljs-string\">\"%b\"<\/span>).dt.month\n\ndfm = dfm.sort_values(by=[<span class=\"hljs-string\">'month_number'<\/span>])\n\ndfm.plot(x=<span class=\"hljs-string\">'month'<\/span>,y=<span class=\"hljs-string\">'Sales of shampoo over a three year period'<\/span>,figsize=(<span class=\"hljs-number\">15<\/span>,<span class=\"hljs-number\">6<\/span>),linestyle=<span class=\"hljs-string\">'-'<\/span>, marker=<span class=\"hljs-string\">'s'<\/span>, markerfacecolor=<span class=\"hljs-string\">'b'<\/span>,color=<span class=\"hljs-string\">'y'<\/span>,markersize=<span class=\"hljs-number\">11<\/span>)\n\nplt.xlabel(<span class=\"hljs-string\">'Year-Month'<\/span>)\nplt.ylabel(<span class=\"hljs-string\">'Mean Sales'<\/span>)\n<\/code><\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2020\/11\/image7.png\" alt=\"\" width=\"891\" height=\"371\"\n  class=\"aligncenter size-full wp-image-27011\" srcset=\"\/wp-content\/uploads\/2020\/11\/image7.png 891w, \/wp-content\/uploads\/2020\/11\/image7-300x125.png 300w, \/wp-content\/uploads\/2020\/11\/image7-768x320.png 768w, \/wp-content\/uploads\/2020\/11\/image7-600x250.png 600w\" sizes=\"(max-width: 891px) 100vw, 891px\" \/><\/p>\n<p>We see that the sales indeed peek around November and decline. <\/p>\n<p>Another nice way of visualising this is through a 2D heat map.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"lang-python\">x=dfm[<span class=\"hljs-string\">'month_number'<\/span>]\ny=dfm[<span class=\"hljs-string\">'Sales of shampoo over a three year period'<\/span>]\nplt.hist2d(x, y)\nplt.xlabel(<span class=\"hljs-string\">'Month'<\/span>)\nplt.ylabel(<span class=\"hljs-string\">'Mean Sales'<\/span>)\n<\/code><\/pre>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2020\/11\/image3.png\" alt=\"\" width=\"395\" height=\"262\"\n  class=\"aligncenter size-full wp-image-27012\" srcset=\"\/wp-content\/uploads\/2020\/11\/image3.png 395w, \/wp-content\/uploads\/2020\/11\/image3-300x199.png 300w\" sizes=\"(max-width: 395px) 100vw, 395px\" \/><\/p>\n<p>Next we plot some basic time series based charts. <\/p>\n<h4 id=\"lag-plot\">Lag Plot<\/h4>\n<p>A lag plot is a simple plot where the y axis has a certain amount to lag (default 1) to the x axis. Lag plots can be used to check if a dataset is random or not. In time series datasets we should see a trend <\/p>\n<div class=\"clipboard\">\n<pre><code class=\"lang-python\">pd<span class=\"hljs-selector-class\">.plotting<\/span><span class=\"hljs-selector-class\">.lag_plot<\/span>(df[<span class=\"hljs-string\">'Sales of shampoo over a three year period'<\/span>])\n<\/code><\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"images\/image4.png\" alt=\"\"><\/p>\n<p> We can see that there is an upward linear trend with some outliers.<\/p>\n<h4 id=\"autocorrelogram-or-autocorrelation-plot\">Autocorrelogram or Autocorrelation Plot<\/h4>\n<p>Autocorrelogram are another way of checking for randomness in data. We compute autocorrelation for the data values at varying time lags. The plot shows lag along the x-axis and the correlation on the y-axis. Dotted lines indicate any correlation values above those lines are statistically significant.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"lang-python\">pd<span class=\"hljs-selector-class\">.plotting<\/span><span class=\"hljs-selector-class\">.autocorrelation_plot<\/span>(df[<span class=\"hljs-string\">'Sales of shampoo over a three year period'<\/span>])\n<\/code><\/pre>\n<\/div>\n<p><img fetchpriority=\"high\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2020\/11\/image8.png\" alt=\"\" width=\"347\" height=\"294\"\n  class=\"aligncenter size-full wp-image-27009\" srcset=\"\/wp-content\/uploads\/2020\/11\/image8.png 347w, \/wp-content\/uploads\/2020\/11\/image8-300x254.png 300w\" sizes=\"(max-width: 347px) 100vw, 347px\" \/><\/p>\n<p>We see that there is a positive autocorrelation in the dataset for low lags. The higher lags don&#39;t make sense as we have data for only three years. A nicer plot is provided by the <code>statmodel<\/code> library.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"lang-python\">import statsmodels<span class=\"hljs-selector-class\">.api<\/span> as sm\nsm<span class=\"hljs-selector-class\">.graphics<\/span><span class=\"hljs-selector-class\">.tsa<\/span><span class=\"hljs-selector-class\">.plot_acf<\/span>(df[<span class=\"hljs-string\">\"Sales of shampoo over a three year period\"<\/span>])\n<\/code><\/pre>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2020\/11\/image9.png\" alt=\"\" width=\"386\" height=\"264\"\n  class=\"aligncenter size-full wp-image-27014\" srcset=\"\/wp-content\/uploads\/2020\/11\/image9.png 386w, \/wp-content\/uploads\/2020\/11\/image9-300x205.png 300w\" sizes=\"(max-width: 386px) 100vw, 386px\" \/><\/p>\n<p>Now we can see the strong positive correlation upto lag = 12.<\/p>\n<h4 id=\"seasonality\">Seasonality<\/h4>\n<p>Here is where the statmodel ts functions will come handy. We will do a simple seasonality analysis to see the trend in data. The seasonal_decompose is used to plot the seanlity. However, <code>ts<\/code> requires the data to have a dateIndex so we create a dummy DateIndex.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"lang-python\">df[<span class=\"hljs-string\">\"month_number\"<\/span>] = pd.to_datetime(df[<span class=\"hljs-string\">\"month\"<\/span>], format= <span class=\"hljs-string\">\"%b\"<\/span>)<span class=\"hljs-selector-class\">.dt<\/span><span class=\"hljs-selector-class\">.month<\/span>\ndf<span class=\"hljs-selector-class\">.year<\/span> = df<span class=\"hljs-selector-class\">.year<\/span><span class=\"hljs-selector-class\">.astype<\/span>(<span class=\"hljs-string\">\"int\"<\/span>)\ndf[<span class=\"hljs-string\">\"date\"<\/span>] = pd.to_datetime(((df.year+<span class=\"hljs-number\">2000<\/span>)*<span class=\"hljs-number\">10000<\/span>+df.month_number*<span class=\"hljs-number\">100<\/span>+<span class=\"hljs-number\">1<\/span>).apply(str),format=<span class=\"hljs-string\">'%Y%m%d'<\/span>)\ndf = df.set_index(<span class=\"hljs-string\">\"date\"<\/span>)\n<\/code><\/pre>\n<\/div>\n<div class=\"clipboard\">\n<pre><code class=\"lang-python\">from statsmodels.tsa.seasonal import seasonal_decompose\n\n\ndecomp = seasonal_decompose(x=df[[<span class=\"hljs-string\">\"Sales of shampoo over a three year period\"<\/span>]], model='<span class=\"hljs-built_in\">additive<\/span>')\nest_trend = decomp.trend\nest_seasonal = decomp.seasonal\n\nfig, <span class=\"hljs-built_in\">axes<\/span> = plt.subplots(<span class=\"hljs-number\">3<\/span>, <span class=\"hljs-number\">1<\/span>)\nfig.set_figheight(<span class=\"hljs-number\">10<\/span>)\nfig.set_figwidth(<span class=\"hljs-number\">15<\/span>)\n<span class=\"hljs-built_in\">axes<\/span>[<span class=\"hljs-number\">0<\/span>].plot(df[<span class=\"hljs-string\">\"Sales of shampoo over a three year period\"<\/span>], <span class=\"hljs-built_in\">label<\/span>='Original')\n<span class=\"hljs-built_in\">axes<\/span>[<span class=\"hljs-number\">0<\/span>].<span class=\"hljs-built_in\">legend<\/span>()\n<span class=\"hljs-built_in\">axes<\/span>[<span class=\"hljs-number\">1<\/span>].plot(est_trend, <span class=\"hljs-built_in\">label<\/span>='Trend',<span class=\"hljs-built_in\">color<\/span>=<span class=\"hljs-string\">\"b\"<\/span>)\n<span class=\"hljs-built_in\">axes<\/span>[<span class=\"hljs-number\">1<\/span>].<span class=\"hljs-built_in\">legend<\/span>()\n<span class=\"hljs-built_in\">axes<\/span>[<span class=\"hljs-number\">2<\/span>].plot(est_seasonal, <span class=\"hljs-built_in\">label<\/span>='Seasonality',<span class=\"hljs-built_in\">color<\/span>='r')\n<span class=\"hljs-built_in\">axes<\/span>[<span class=\"hljs-number\">2<\/span>].<span class=\"hljs-built_in\">legend<\/span>()\n<\/code><\/pre>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2020\/11\/image6.png\" alt=\"\" width=\"894\" height=\"576\"\n  class=\"aligncenter size-full wp-image-27015\" srcset=\"\/wp-content\/uploads\/2020\/11\/image6.png 894w, \/wp-content\/uploads\/2020\/11\/image6-300x193.png 300w, \/wp-content\/uploads\/2020\/11\/image6-768x495.png 768w, \/wp-content\/uploads\/2020\/11\/image6-600x387.png 600w\" sizes=\"(max-width: 894px) 100vw, 894px\" \/><\/p>\n<p>Alternative we can plot boxplots as the month level<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"lang-python\">df.boxplot(figsize=(<span class=\"hljs-number\">15<\/span>,<span class=\"hljs-number\">6<\/span>),<span class=\"hljs-keyword\">by<\/span>='month_number',column='Sales <span class=\"hljs-keyword\">of<\/span> shampoo <span class=\"hljs-keyword\">over<\/span> a three <span class=\"hljs-built_in\">year<\/span> period')\n<\/code><\/pre>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2020\/11\/image2.png\" alt=\"\" width=\"904\" height=\"404\"\n  class=\"aligncenter size-full wp-image-27016\" srcset=\"\/wp-content\/uploads\/2020\/11\/image2.png 904w, \/wp-content\/uploads\/2020\/11\/image2-300x134.png 300w, \/wp-content\/uploads\/2020\/11\/image2-768x343.png 768w, \/wp-content\/uploads\/2020\/11\/image2-600x268.png 600w\" sizes=\"(max-width: 904px) 100vw, 904px\" \/><\/p>\n<p>We can see an upward trend and mild seasonality of peaks in November. However, the dataset is too small to make<br \/>\n  conclusive statements about the seasonality. <\/p>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>In this post we first learned how to set up GridDB and python. Next we discussed some common visualization methods for time series. Finally, we did some trend, autocorrelation and seasonality analysis and plotted corresponding plots. For more advanced visualization and dashboarding check out <a\n    href=\"https:\/\/medium.com\/@rraiitk\/building-dashboards-using-dash-200-lines-of-code-ae0be08d805b\">this post<\/a>.<\/p>\n<h3 id=\"source-code\"> Source Code <\/h3>\n<p><a href=\"https:\/\/griddb.net\/en\/download\/27093\/\"> <span class=\"download-button\"> Click here to download the full source code <\/span><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Data is general is a large heap of numbers, to a non-expert these numbers may be more confusing than they are informative. With the advent of big data, even experts have a difficult time making sense of data. This is where visualization comes in. Data visualization can be thought of as the graphical representation [&hellip;]<\/p>\n","protected":false},"author":41,"featured_media":27016,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[121],"tags":[],"class_list":["post-46620","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Data Visualization with Python Matplotlib and GridDB | GridDB: Open Source Time Series Database for IoT<\/title>\n<meta name=\"description\" content=\"Introduction Data is general is a large heap of numbers, to a non-expert these numbers may be more confusing than they are informative. With the advent of\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/griddb.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Data Visualization with Python Matplotlib and GridDB | GridDB: Open Source Time Series Database for IoT\" \/>\n<meta property=\"og:description\" content=\"Introduction Data is general is a large heap of numbers, to a non-expert these numbers may be more confusing than they are informative. With the advent of\" \/>\n<meta property=\"og:url\" content=\"https:\/\/griddb.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/\" \/>\n<meta property=\"og:site_name\" content=\"GridDB: Open Source Time Series Database for IoT\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/griddbcommunity\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-13T08:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-11-13T20:55:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/wp-content\/uploads\/2020\/11\/image2.png\" \/>\n\t<meta property=\"og:image:width\" content=\"904\" \/>\n\t<meta property=\"og:image:height\" content=\"404\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"griddb-admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@GridDBCommunity\" \/>\n<meta name=\"twitter:site\" content=\"@GridDBCommunity\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"griddb-admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/\"},\"author\":{\"name\":\"griddb-admin\",\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233\"},\"headline\":\"Data Visualization with Python Matplotlib and GridDB\",\"datePublished\":\"2020-11-13T08:00:00+00:00\",\"dateModified\":\"2025-11-13T20:55:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/\"},\"wordCount\":1060,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/griddb.net\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2020\/11\/image2.png\",\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/griddb.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/\",\"url\":\"https:\/\/griddb.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/\",\"name\":\"Data Visualization with Python Matplotlib and GridDB | GridDB: Open Source Time Series Database for IoT\",\"isPartOf\":{\"@id\":\"https:\/\/griddb.net\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2020\/11\/image2.png\",\"datePublished\":\"2020-11-13T08:00:00+00:00\",\"dateModified\":\"2025-11-13T20:55:03+00:00\",\"description\":\"Introduction Data is general is a large heap of numbers, to a non-expert these numbers may be more confusing than they are informative. With the advent of\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/griddb.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/#primaryimage\",\"url\":\"\/wp-content\/uploads\/2020\/11\/image2.png\",\"contentUrl\":\"\/wp-content\/uploads\/2020\/11\/image2.png\",\"width\":904,\"height\":404},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/griddb.net\/en\/#website\",\"url\":\"https:\/\/griddb.net\/en\/\",\"name\":\"GridDB: Open Source Time Series Database for IoT\",\"description\":\"GridDB is an open source time-series database with the performance of NoSQL and convenience of SQL\",\"publisher\":{\"@id\":\"https:\/\/griddb.net\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/griddb.net\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/griddb.net\/en\/#organization\",\"name\":\"Fixstars\",\"url\":\"https:\/\/griddb.net\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png\",\"contentUrl\":\"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png\",\"width\":200,\"height\":83,\"caption\":\"Fixstars\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/griddbcommunity\/\",\"https:\/\/x.com\/GridDBCommunity\",\"https:\/\/www.linkedin.com\/company\/griddb-by-toshiba\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233\",\"name\":\"griddb-admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g\",\"caption\":\"griddb-admin\"},\"url\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/author\/griddb-admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Data Visualization with Python Matplotlib and GridDB | GridDB: Open Source Time Series Database for IoT","description":"Introduction Data is general is a large heap of numbers, to a non-expert these numbers may be more confusing than they are informative. With the advent of","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/griddb.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/","og_locale":"en_US","og_type":"article","og_title":"Data Visualization with Python Matplotlib and GridDB | GridDB: Open Source Time Series Database for IoT","og_description":"Introduction Data is general is a large heap of numbers, to a non-expert these numbers may be more confusing than they are informative. With the advent of","og_url":"https:\/\/griddb.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/","og_site_name":"GridDB: Open Source Time Series Database for IoT","article_publisher":"https:\/\/www.facebook.com\/griddbcommunity\/","article_published_time":"2020-11-13T08:00:00+00:00","article_modified_time":"2025-11-13T20:55:03+00:00","og_image":[{"width":904,"height":404,"url":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/wp-content\/uploads\/2020\/11\/image2.png","type":"image\/png"}],"author":"griddb-admin","twitter_card":"summary_large_image","twitter_creator":"@GridDBCommunity","twitter_site":"@GridDBCommunity","twitter_misc":{"Written by":"griddb-admin","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/griddb.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/#article","isPartOf":{"@id":"https:\/\/griddb.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/"},"author":{"name":"griddb-admin","@id":"https:\/\/griddb.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233"},"headline":"Data Visualization with Python Matplotlib and GridDB","datePublished":"2020-11-13T08:00:00+00:00","dateModified":"2025-11-13T20:55:03+00:00","mainEntityOfPage":{"@id":"https:\/\/griddb.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/"},"wordCount":1060,"commentCount":0,"publisher":{"@id":"https:\/\/griddb.net\/en\/#organization"},"image":{"@id":"https:\/\/griddb.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2020\/11\/image2.png","articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/griddb.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/griddb.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/","url":"https:\/\/griddb.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/","name":"Data Visualization with Python Matplotlib and GridDB | GridDB: Open Source Time Series Database for IoT","isPartOf":{"@id":"https:\/\/griddb.net\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/griddb.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/#primaryimage"},"image":{"@id":"https:\/\/griddb.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2020\/11\/image2.png","datePublished":"2020-11-13T08:00:00+00:00","dateModified":"2025-11-13T20:55:03+00:00","description":"Introduction Data is general is a large heap of numbers, to a non-expert these numbers may be more confusing than they are informative. With the advent of","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/griddb.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb.net\/en\/blog\/data-visualization-with-python-matplotlib-and-griddb\/#primaryimage","url":"\/wp-content\/uploads\/2020\/11\/image2.png","contentUrl":"\/wp-content\/uploads\/2020\/11\/image2.png","width":904,"height":404},{"@type":"WebSite","@id":"https:\/\/griddb.net\/en\/#website","url":"https:\/\/griddb.net\/en\/","name":"GridDB: Open Source Time Series Database for IoT","description":"GridDB is an open source time-series database with the performance of NoSQL and convenience of SQL","publisher":{"@id":"https:\/\/griddb.net\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/griddb.net\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/griddb.net\/en\/#organization","name":"Fixstars","url":"https:\/\/griddb.net\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb.net\/en\/#\/schema\/logo\/image\/","url":"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png","contentUrl":"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png","width":200,"height":83,"caption":"Fixstars"},"image":{"@id":"https:\/\/griddb.net\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/griddbcommunity\/","https:\/\/x.com\/GridDBCommunity","https:\/\/www.linkedin.com\/company\/griddb-by-toshiba"]},{"@type":"Person","@id":"https:\/\/griddb.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233","name":"griddb-admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb.net\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g","caption":"griddb-admin"},"url":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/author\/griddb-admin\/"}]}},"_links":{"self":[{"href":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/wp-json\/wp\/v2\/posts\/46620","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/wp-json\/wp\/v2\/comments?post=46620"}],"version-history":[{"count":1,"href":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/wp-json\/wp\/v2\/posts\/46620\/revisions"}],"predecessor-version":[{"id":51296,"href":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/wp-json\/wp\/v2\/posts\/46620\/revisions\/51296"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/wp-json\/wp\/v2\/media\/27016"}],"wp:attachment":[{"href":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/wp-json\/wp\/v2\/media?parent=46620"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/wp-json\/wp\/v2\/categories?post=46620"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/wp-json\/wp\/v2\/tags?post=46620"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}