Plot Candlestick Chart using mplfinance module in Python Last Updated : 16 Dec, 2021 Comments Improve Suggest changes Like Article Like Report Candlestick chart are also known as a Japanese chart. These are widely used for technical analysis in trading as they visualize the price size within a period. They have four points Open, High, Low, Close (OHLC). Candlestick charts can be created in python using a matplotlib module called mplfinance. Installation:pip install mplfinancemplfinance.candlestick_ohlc() This function is used to plot Candlestick charts. Syntax: mplfinance.candlestick_ohlc(ax, quotes, width=0.2, colorup='k', colordown='r', alpha=1.0)Parameters: ax: An Axes instance to plot to.quotes: sequence of (time, open, high, low, close, …) sequences.width: Fraction of a day for the rectangle width.colorup: The color of the rectangle where close >= open.colordown: The color of the rectangle where close < open.alpha: (float) The rectangle alpha level. Returns: returns (lines, patches) where lines are a list of lines added and patches is a list of the rectangle patches added. To plot the chart, we will take data from NSE for the period 01-07-2020 to 15-07-2020, the data is available for download in a csv file, or can be downloaded from here. For this example, it is saved as 'data.csv'.We will use the pandas library to extract the data for plotting from data.csv. Below is the implementation: Python3 # import required packages import matplotlib.pyplot as plt from mplfinance import candlestick_ohlc import pandas as pd import matplotlib.dates as mpdates plt.style.use('dark_background') # extracting Data for plotting df = pd.read_csv('data.csv') df = df[['Date', 'Open', 'High', 'Low', 'Close']] # convert into datetime object df['Date'] = pd.to_datetime(df['Date']) # apply map function df['Date'] = df['Date'].map(mpdates.date2num) # creating Subplots fig, ax = plt.subplots() # plotting the data candlestick_ohlc(ax, df.values, width = 0.6, colorup = 'green', colordown = 'red', alpha = 0.8) # allow grid ax.grid(True) # Setting labels ax.set_xlabel('Date') ax.set_ylabel('Price') # setting title plt.title('Prices For the Period 01-07-2020 to 15-07-2020') # Formatting Date date_format = mpdates.DateFormatter('%d-%m-%Y') ax.xaxis.set_major_formatter(date_format) fig.autofmt_xdate() fig.tight_layout() # show the plot plt.show() Output : Candlestick Chart Comment More infoAdvertise with us Next Article Plot Candlestick Chart using mplfinance module in Python M maryamnadeem20 Follow Improve Article Tags : Python Python-matplotlib Data Visualization Practice Tags : python Similar Reads Python | Basic Gantt chart using Matplotlib Prerequisites : Matplotlib IntroductionIn this article, we will be discussing how to plot a Gantt Chart in Python using Matplotlib.A Gantt chart is a graphical depiction of a project schedule or task schedule (In OS). It's is a type of bar chart that shows the start and finish dates of several eleme 3 min read Bubble chart using Plotly in Python Plotly is a Python library which is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot, and many more. It is mainly used in data analysis as well as financial analysis. Plotly is an interactive visualization librar 3 min read Plotting graphs using Python's plotly and cufflinks module plotly is a Python library which is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization library 2 min read Saving a Plot as an Image in Python Sometimes we want to save charts and graphs as images or even images as a file on disk for use in presentations to present reports. And in some cases, we need to prevent the plot and images for future use. In this article, we'll see a way to save a plot as an image by converting it to an image, and 6 min read How to Plot Mfcc in Python Using Matplotlib? Mel-frequency cepstral coefficients (MFCC) are widely used in audio signal processing and speech recognition tasks. They represent the spectral characteristics of an audio signal and are commonly used as features for various machine-learning applications. In this article, we will explore how to comp 2 min read Python | Plotting charts in excel sheet using openpyxl module | Set â 2 Prerequisite: Python | Plotting charts in excel sheet using openpyxl module | Set â 1 Openpyxl is a Python library using which one can perform multiple operations on excel files like reading, writing, arithmetic operations and plotting graphs. Charts are composed of at least one series of one or mor 6 min read Python | Plotting charts in excel sheet using openpyxl module | Set - 1 Prerequisite: Reading & Writing to excel sheet using openpyxl Openpyxl is a Python library using which one can perform multiple operations on excel files like reading, writing, arithmetic operations and plotting graphs. Let's see how to plot different charts using realtime data. Charts are compo 6 min read 3D Line Plots using Plotly in Python Plotly is a Python library that is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization library 2 min read How to Create a Candlestick Chart in Matplotlib? A candlestick chart, often known as a Japanese candlestick chart, is a financial chart that shows the price movement of stocks, derivatives, and other financial instruments in real-time, there are simply four essential components that must be examined. The open, high, low, and close are the four key 4 min read How to Add Labels in a Plot using Python? Prerequisites: Python Matplotlib In this article, we will discuss adding labels to the plot using Matplotlib in Python. But first, understand what are labels in a plot. The heading or sub-heading written at the vertical axis (say Y-axis) and the horizontal axis(say X-axis) improves the quality of u 3 min read Like