7

I want to make following diagram-

enter image description here Below is my code of smartdiagram-

\begin{figure}
    \centering
    \smartdiagramset{back arrow disabled=true,
        module minimum width=2cm,
        module minimum height=2cm,
        module x sep=3cm,
        text width=2cm,
        additions={
            additional item offset=0.5cm,
            additional item border color=red,
            additional connections disabled=false,
            additional arrow color=red,
            additional arrow tip=stealth,
            additional arrow line width=1pt,
            additional item width=2cm
        }
    }
    \smartdiagramadd[flow diagram:horizontal]{
        Reward Function (R), Inverse Reinforcement Learning, Optimal Policy ($\pi$)
        }{below of module1/R that explains expert trajectories,above of module2/Environment Model (MDP), below of module3/Expert trajectories}
\end{figure}

This is the generated diagram-

enter image description here

I want to changes following things in this diagram-

  1. The direction of arrow (From right to left and from top to bottom)
  2. The look and feel of additional modules similar to other
  3. The arrow corresponding to additional modules similar to other
1
  • 1
    Please always post compilable code as this makes it much easier to help and much more likely that a solution will help. You need at least a class, a document environment and the package for drawing the diagrams.
    – cfr
    May 15, 2016 at 20:05

2 Answers 2

8

Changing arrow style from the default <- to -> ensures that the arrows go in the correct direction for the main nodes:

reversed arrows

For a uniform look to the arrows remove

additional arrow tip=stealth,
additional arrow line width=1pt,

uniform arrows

[I'm not sure if you want this or not.]

To support the arrows going in the different directions for the additional modules, you need to leave the automatic connections disabled and add them afterwards by hand.

\smartdiagramconnect{<-}{module2/additional-module2}
\smartdiagramconnect{<-}{additional-module1/module1}
\smartdiagramconnect{<-}{module3/additional-module3}

To change the look of the additional modules, you can adapt their style using the keys described in the manual.

  additions={
    additional item offset=0.5cm,
    additional item border color=red,
    additional arrow color=red,
    additional item width=2cm,
    additional item height=2cm,
    additional item text width=3cm,
    additional item bottom color=red!50,
    additional item shadow=drop shadow,
  }

manually added arrows in various directions

Complete code:

\documentclass{article}
\usepackage{smartdiagram}
\usesmartdiagramlibrary{additions}
\begin{document}
\smartdiagramset{%
  back arrow disabled=true,
  module minimum width=2cm,
  module minimum height=2cm,
  module x sep=3cm,
  text width=2cm,
  arrow style=->,
  additions={
    additional item offset=0.5cm,
    additional item border color=red,
    additional arrow color=red,
    additional item width=2cm,
    additional item height=2cm,
    additional item text width=3cm,
    additional item bottom color=red!50,
    additional item shadow=drop shadow,
  }
}
\smartdiagramadd[flow diagram:horizontal]{
  Reward Function (R), Inverse Reinforcement Learning, Optimal Policy ($\pi$)
}{below of module1/R that explains expert trajectories,above of module2/Environment Model (MDP), below of module3/Expert trajectories}
\smartdiagramconnect{<-}{module2/additional-module2}
\smartdiagramconnect{<-}{additional-module1/module1}
\smartdiagramconnect{<-}{module3/additional-module3}
\end{document}
3

I never use smartdiagram so I suggest a solution which instead use the pure TikZ picture:

enter image description here

\documentclass[border=3mm,
               tikz]{standalone}
\usetikzlibrary{arrows.meta, positioning, shadows}

    \begin{document}
\begin{tikzpicture}[
    node distance = 7mm and 9mm,
   MN/.style args = {#1/#2}{
            draw=#1,% line color
            top color=#2!10,
            bottom color=#2!80,
            rounded corners, thick,
            text width=27mm, minimum height=13mm, inner sep=1mm, 
            align=flush center},
      line/.style = {line width=2mm,
            draw=#1,%line color
            -{Triangle[length=2.8mm,width=4mm,fill=#1]},
            shorten >=1mm, shorten <=1mm
            },
        ds/.style = {drop shadow}
                    ]
%---
\linespread{0.9}
% bottom
\node (n1) [MN=red/white]                   {R that explains expert trajectories};
% middle
\node (n2) [MN=gray/red, ds,above=of n1]    {Reward Function (R)};
\node (n3) [MN=gray/cyan,ds,right=of n2]    {Inverse Reinforcement Learning};
\node (n4) [MN=gray/blue,ds,right=of n3]    {Optimal Policy ($\pi$)};
% bottom
\node (n5) [MN=red/white,below=of n4]       {Expert trajectories (R)};
% top
\node (n6) [MN=red/white,above=of n3]       {Environment Model (MDP)};
% lines
\draw[line=red]     (n6) edge (n3)
                    (n1) edge (n2)  (n5) to (n4);
\draw[line=cyan]    (n2) edge (n3);
\draw[line=blue]    (n3) edge (n4);
\end{tikzpicture}
    \end{document}
1
  • 1
    I am big fan of tikz, I always prefer it. But recently I saw smartdiagram, and I thought of using it. I think tikz is the best option always. Thank you very much.
    – ravi
    May 17, 2016 at 3:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .