x      = 0
    y      = height
    ax.text(x, y, txt, ha="center", va="center")

ax.set_xlabel(r"$[\mathrm{s}^{-1}]$")

ax.spines["top"]  .set_visible(False)
ax.spines["left"] .set_visible(False)
ax.spines["right"].set_visible(False)
ax.get_yaxis().set_visible(False)

PlotHelper.makePlotPretty(ax, legend=False, rotation=45)
ax.grid(False)

# Make legend manually
handles = (holeRects[0], blobRects[0])
labels  = ("$\mathrm{Holes}$",\
           "$\mathrm{Blobs}$",\
           )

fig.suptitle(r"$\mathrm{Average\;blobs\;and\;holes\;per\;second}$", y=1.1)
fig.legend(handles                      ,\
           labels                       ,\
           bbox_to_anchor=(1.02, 1.0)   ,\
           loc="upper left"             ,\
           borderaxespad=0.             ,\
           bbox_transform = ax.transAxes,\
           )

PlotHelper.savePlot(fig, "nnScanBlobCount.pdf")
Exemple #2
0
                 "edgecolor":"none" ,\
                 "boxstyle" :"round",\
                 "alpha"    :0.9},\
           )

ddtTxt = r"$\partial_t j_\parallel$"
newAx.text(1.4, 0, ddtTxt, color="k",\
           va="center", ha="center", size="x-large",\
           bbox={"facecolor":"white",\
                 "edgecolor":"none" ,\
                 "boxstyle" :"round",\
                 "alpha"    :0.9},\
           )

newAx.set_xlabel(r"$z\;[\mathrm{m}]$")
newAx.set_ylabel(r"$[\mathrm{C}\mathrm{m}^{-2}\mathrm{s}^{-2}]$")

# Create new title
theSplit = suptitle.split("=")
rho = float(theSplit[1].split("$")[2]) * rhoS
t   = eval(theSplit[-1].split("$")[2].\
           replace("{","").replace("}","").replace("\\cdot 10^","e"))/omCI
newAx.set_title((r"$\rho={}\;\mathrm{{m}}\quad"
                 r"\theta=0^{{\circ}}\quad t={}\;\mathrm{{s}}$").\
        format(plotNumberFormatter(rho,0).replace("$",""),\
               plotNumberFormatter(t,0)  .replace("$","")\
        ))

PlotHelper.makePlotPretty(newAx, legend=False)
PlotHelper.savePlot(fig, "jParBalanceNy{}.pdf".format(ny))
Exemple #3
0
# Create the figure
fig, ax = plt.subplots(figsize=SizeMaker.standard(a=0.5, s=0.5))

for key in keys:
    d = data[key]
    ax.bar(d["x"], d["mean"], yerr=d["std"], label=key)

PlotHelper.makePlotPretty(ax)
ax.xaxis.grid(False)
ax.xaxis.set_ticks(tickVals)
ax.xaxis.set_ticklabels(
    ("Initial\nphase", "Expand\nphase", "Linear\nphase", "Turbulent\nphase"))
ax.set_ylabel("$\%$")

# Move legend outside
handles, labels = ax.get_legend_handles_labels()

# Remove old legend
leg = ax.legend()
leg.remove()
fig.legend(handles,\
           labels ,\
           bbox_to_anchor=(1.05, 1.0),\
           loc="upper left",\
           borderaxespad=0.,\
           bbox_transform = ax.transAxes,\
           )

PlotHelper.savePlot(
    fig, "PercentagesBScanB0{}".format(B0).replace(".", "_") + ".pdf")
Exemple #4
0
    axes = (nAx, phiAx, jParAx, omAx, uiAx, sAx, ueAx)
    colors = seqCMap3(np.linspace(0, 1, len(axes)))

    # Recolor the lines
    for ax, color in zip(axes, colors):
        line = ax.get_lines()[0]
        line.set_color(color)
        # NOTE: Using the designated setter gives a comparion error
        line._markerfacecolor = color
        line._markeredgecolor = color

        # To fix the legends, it seems like the easiest to do is to
        # recreate them
        handles, labels = ax.get_legend_handles_labels()
        leg = ax.legend()
        # Remake legend
        leg.remove()
        ax.legend(handles         ,\
                  labels          ,\
                  loc="upper left",\
                 )

    if direction == "radial":
        fileName = "B010RadBous.pdf"
    elif direction == "parallel":
        fileName = "B010ParBous.pdf"

    # Let pdfcrop do the cropping as "tigth" cuts some text
    PlotHelper.savePlot(fig, fileName, crop=False)
    Popen("pdfcrop {0} {0}".format(fileName), shell=True).wait()
parAx.set_xlabel(r"$[\mathrm{s}^{-1}]$")
parAx.set_title(r"$\mathrm{Parallel}$")

parAx.spines["top"]  .set_visible(False)
parAx.spines["left"] .set_visible(False)
parAx.spines["right"].set_visible(False)
parAx.get_yaxis().set_visible(False)

PlotHelper.makePlotPretty(parAx, xbins=5, legend=False, rotation=45)
parAx.grid(False)

# Make legend manually
handles = (perpRects[0], ionRects[0], elRects[0])
labels  = ("$\mathrm{Both}$"     ,\
           "$\mathrm{Ions}$"     ,\
           "$\mathrm{Electrons}$",\
           )

fig.legend(handles                         ,\
           labels                          ,\
           bbox_to_anchor=(1.25, 1.0)      ,\
           loc="upper left"                ,\
           borderaxespad=0.                ,\
           bbox_transform = parAx.transAxes,\
           )

fig.suptitle(r"$\mathrm{Average\;particle\;flux}$", y=1.3)

PlotHelper.savePlot(fig, "BScanTotalFlux.pdf")
Exemple #6
0
    yLabels.append(ax.get_ylabel())
    ax.cla()

    for y, yDown, yUp, color in zip(meanY, yDownY, yUpY, colors):
        yDown = np.array(yDown) - np.array(y)
        yUp = np.array(y) - np.array(yUp)
        yerr = (np.array(yDown), np.array(yUp))

        # Replot
        ax.errorbar(x                ,\
                    y                ,\
                    color = color    ,\
                    yerr  = yerr     ,\
                    **errorbarOptions)

        PlotHelper.makePlotPretty(ax, legend=False, rotation=45)

# Remove x axis on imAx
imAx.set_xticklabels(imAx.get_xticklabels(), visible=False)

# Set proper ticks
reAx.xaxis.set_ticks(x)
reAx.set_xticklabels([r"${:d}\;\%$".format(int(i)) for i in x])

# Set the labels
imAx.set_ylabel(yLabels[0])
reAx.set_ylabel(yLabels[1])
reAx.set_xlabel(r"$\mathrm{Ionization\;degree}$")

PlotHelper.savePlot(fig, "growthRatesNnModes.pdf")
Exemple #7
0
ax.bar(linearXvals, linearMeans,\
        yerr=linearStds, label="Linear phase")
ax.bar(turbulenceXvals, turbulenceMeans,\
        yerr=turbulenceStds, label="Turbulent phase")

PlotHelper.makePlotPretty(ax)
ax.xaxis.grid(False)
ax.xaxis.set_ticks(tickVals)

n0 = 1e19
nns = n0 / (n0 + np.array([float(nn) for nn in nns])) * 100
tickLabels = tuple(r"${:d}\%$".format(int(np.ceil(nn))) for nn in nns)
ax.xaxis.set_ticklabels(tickLabels)
ax.set_xlabel("$d$")
ax.set_ylabel("RHS iterations per time step")

# Move legend outside
handles, labels = ax.get_legend_handles_labels()
# Remove old legend
leg = ax.legend()
leg.remove()
fig.legend(handles,\
           labels ,\
           bbox_to_anchor=(1.05, 1.0),\
           loc="upper left",\
           borderaxespad=0.,\
           bbox_transform = ax.transAxes,\
           )

PlotHelper.savePlot(fig, "RHSEvalsPerTimeNeutralScan.pdf")
                 "edgecolor":"none" ,\
                 "boxstyle" :"round",\
                 "alpha"    :0.9},\
           )

normalAx.set_xlabel(r"$\rho\;[\mathrm{m}]$")
normalAx.set_ylabel(r"$[\mathrm{C}\mathrm{m}^{-2}\mathrm{s}^{-2}]$")

# Create new title
normalAx.set_title(r"$d=100\%$")

PlotHelper.makePlotPretty(normalAx, legend=False, rotation=45)
#}}}

# Create new title
theSplit = suptitle.split("=")
rho = float(theSplit[1].split("$")[2]) * rhoS
t   = eval(theSplit[-1].split("$")[2].\
           replace("{","").replace("}","").replace("\\cdot 10^","e"))/omCI

fig.suptitle((r"$z={}\;\mathrm{{m}}\quad"
                 r"\theta=0^{{\circ}}\quad t={}\;\mathrm{{s}}$").\
        format(plotNumberFormatter(rho,0).replace("$",""),\
               plotNumberFormatter(t,0)  .replace("$","")\
        ),
        y = 1.15
        )

fig.subplots_adjust(wspace=0.7)
PlotHelper.savePlot(fig, "jParBalanceNnCompareRad.pdf")
    line.set_markersize(7)

handles, labels = axUp.get_legend_handles_labels()

leg = axUp.legend()

# Remove old legend
leg.remove()

fig.legend(handles,\
           labels,\
           bbox_to_anchor=(1.05, 1.0),\
           loc="upper left",\
           borderaxespad=0.,\
           bbox_transform = axUp.transAxes,\
           )

# Tweak the size a bit
fig.set_figwidth(2.0)
fig.set_figheight(4.0)

# Modify title position
t = fig.texts[0]
pos = list(t.get_position())
pos[1] = 1.05
t.set_transform(axUp.transAxes)
t.set_position(pos)
t.set_va("bottom")

PlotHelper.savePlot(fig, "test2.pdf")
Exemple #10
0
        # Replot
        newAx.errorbar(x                ,\
                       y                ,\
                       color = color    ,\
                       yerr  = yerr     ,\
                       **errorbarOptions)

        newAx.set_ylabel(ax.get_ylabel())

newAxes[0].set_title(fig.texts[0].get_text())
newAxes[1].set_xlabel(reAx.get_xlabel())
PlotHelper.makePlotPretty(newAxes[0], legend=False, rotation=45)
PlotHelper.makePlotPretty(newAxes[1], legend=False, rotation=45)

# Manually set the x and the y as the figure has different coordinates
x = 0.4
y = -0.4

newFig.legend(handles,\
              newLabels,\
              bbox_to_anchor=(x, y),\
              ncol=2,\
              loc="upper center",\
              borderaxespad=0.,\
              bbox_transform = newAxes[1].transAxes,\
             )

newAxes[0].get_xaxis().set_major_locator(MaxNLocator(integer=True))

PlotHelper.savePlot(newFig, "growthRatesNnScan.pdf")
fig, ax = plt.subplots(figsize=SizeMaker.standard(a=0.5, s=0.5))

for key in keys:
    d = data[key]
    ax.bar(d["x"], d["mean"], yerr=d["std"], label=key)

PlotHelper.makePlotPretty(ax)
ax.xaxis.grid(False)
ax.xaxis.set_ticks(tickVals)
ax.xaxis.set_ticklabels(
    ("Initial\nphase", "Expand\nphase", "Linear\nphase", "Turbulent\nphase"))
ax.set_ylabel("$\%$")

# Move legend outside
handles, labels = ax.get_legend_handles_labels()

# Remove old legend
leg = ax.legend()
leg.remove()
fig.legend(handles,\
           labels ,\
           bbox_to_anchor=(1.05, 1.0),\
           loc="upper left",\
           borderaxespad=0.,\
           bbox_transform = ax.transAxes,\
           )

PlotHelper.savePlot(
    fig,
    "PercentagesNeutralScanB0{}Nn{}".format(B0, nn).replace(".", "_") + ".pdf")
Exemple #12
0
    axes = fig.get_axes()

    for nr, ax in enumerate(axes):
        blobOrHole = "b" if nr == 0 else "h"
        l = ax.get_lines()[0]
        time, dens = l.get_data()
        ax.lines.pop()
        data[key][blobOrHole + "Time"] = time
        data[key][blobOrHole + "Dens"] = dens

# Replot
axes = fig.get_axes()

for nr, ax in enumerate(axes):
    blobOrHole = "b" if nr == 0 else "h"
    for key, c in zip(data.keys(), colors):
        ax.plot(data[key][blobOrHole + "Time"],\
                data[key][blobOrHole + "Dens"],\
                color=c,
                label="${}\sigma$".format(key),\
                alpha=0.75)
        if nr == 0:
            leg = ax.legend(loc       = "best",\
                            fancybox  = True  ,\
                            numpoints = 1     ,\
                            )
            leg.get_frame().set_alpha(0.5)

PlotHelper.savePlot(fig, "blobsAndHoles-{}.pdf".format(scan))
ax.bar(initXvals, initMeans,\
        yerr=initStds, label="Initial phase")
ax.bar(expandXvals, expandMeans,\
        yerr=expandStds, label="Expand phase")
ax.bar(linearXvals, linearMeans,\
        yerr=linearStds, label="Linear phase")
ax.bar(turbulenceXvals, turbulenceMeans,\
        yerr=turbulenceStds, label="Turbulent phase")

PlotHelper.makePlotPretty(ax)
ax.xaxis.grid(False)
ax.xaxis.set_ticks(tickVals)
ax.xaxis.set_ticklabels(B0s)
ax.set_xlabel("$B_0 [T]$")
ax.set_ylabel("RHS iterations\nper time step")

# Move legend outside
handles, labels = ax.get_legend_handles_labels()
# Remove old legend
leg = ax.legend()
leg.remove()
fig.legend(handles,\
           labels ,\
           bbox_to_anchor=(1.05, 1.0),\
           loc="upper left",\
           borderaxespad=0.,\
           bbox_transform = ax.transAxes,\
           )

PlotHelper.savePlot(fig, "RHSEvalsPerTimeBoussinesqScan.pdf")
Exemple #14
0
ax.bar(initXvals, initMeans,\
        yerr=initStds, label="Initial phase")
ax.bar(expandXvals, expandMeans,\
        yerr=expandStds, label="Expand phase")
ax.bar(linearXvals, linearMeans,\
        yerr=linearStds, label="Linear phase")
ax.bar(turbulenceXvals, turbulenceMeans,\
        yerr=turbulenceStds, label="Turbulent phase")

PlotHelper.makePlotPretty(ax)
ax.xaxis.grid(False)
ax.xaxis.set_ticks(tickVals)
ax.xaxis.set_ticklabels(B0s)
ax.set_xlabel("$B_0 [T]$")
ax.set_ylabel("RHS iterations\nper time step")

# Move legend outside
handles, labels = ax.get_legend_handles_labels()
# Remove old legend
leg = ax.legend()
leg.remove()
fig.legend(handles,\
           labels ,\
           bbox_to_anchor=(1.05, 1.0),\
           loc="upper left",\
           borderaxespad=0.,\
           bbox_transform = ax.transAxes,\
           )

PlotHelper.savePlot(fig, "RHSEvalsPerTimeBScan.pdf")
normalAx.text(0.4, 0, ddtTxt, color="k",\
           va="center", ha="center", size=size,\
           bbox={"facecolor":"white",\
                 "edgecolor":"none" ,\
                 "boxstyle" :"round",\
                 "alpha"    :0.9},\
           )

normalAx.set_xlabel(r"$z\;[\mathrm{m}]$")
normalAx.set_ylabel(r"$[\mathrm{m}^{-3}\mathrm{s}^{-2}]$")

# Create new title
normalAx.set_title(r"$d=100\%$")
PlotHelper.makePlotPretty(normalAx, legend=False, rotation=45)
#}}}

# Create new title
theSplit = suptitle.split("=")
rho = float(theSplit[1].split("$")[2])*rhoS
t = eval(theSplit[-1].split("$")[2].\
         replace("{","").replace("}","").replace("\\cdot 10^","e"))/omCI
fig.suptitle((r"$\rho={}\;\mathrm{{m}}\quad"
                 r"\theta=0^{{\circ}}\quad t={}\;\mathrm{{s}}$").\
        format(plotNumberFormatter(rho,0).replace("$",""),\
               plotNumberFormatter(t,0).replace("$","")\
        ),
        y = 1.2
        )
fig.subplots_adjust(wspace=0.7)
PlotHelper.savePlot(fig, "vortDBalanceNnComparePar.pdf")
Exemple #16
0
           )

# Fix labels
old = r"u_{E\times B,\rho}}"
new = r"}\widetilde{u}_{E\times B,\rho}"
ylabel = ax.get_ylabel()
ylabel = ylabel.replace(old, new)
ax.set_ylabel(ylabel)
xlabel = ax.get_xlabel()
xlabel = xlabel.replace(old, new)
ax.set_xlabel(xlabel)

# Add skewness and kurtosis text
# Get the textSize
textPos = (0.5575, 0.935)
# Add text
SKTxt = ax.\
        text(*textPos,\
            "$S \;\;= \;\;{:.2f}$\n $K_E = {:.2f}$".\
            format(PDFStats["skew"], PDFStats["kurtExcess"]),\
            transform = ax.transAxes,\
            ha="left", va="top",\
            bbox={"facecolor":"white", "alpha":0.5, "pad":5},\
            )
SKTxt.set_fontsize(txtSize)

# Resize the figure
_, height = fig.get_size_inches()
fig.set_size_inches((2.70, height * 0.7))
PlotHelper.savePlot(fig, "blobFluxPDF_{}.pdf".format(scan))
Exemple #17
0
    # Manually creating the legend
    handles = []
    for scan in scans:
        curScan = float(scan[4:])
        label = "$B_0 = {}$".format(curScan) + r" $\mathrm{T}$"
        handle = mlines.Line2D([], [],\
                       color  = "k"                    ,\
                       marker = sD[scan]["n"]["marker"],\
                       ls     = sD[scan]["n"]["ls"]    ,\
                       ms     = 5                      ,\
                       alpha  = 0.7                    ,\
                       label  =label)
        handles.append(handle)

    # Put legends outside
    sD[scans[0]]["ue"]["ax"].legend(handles=handles,\
                                    ncol=2,\
                                    bbox_to_anchor=(1.15, 0.25),\
                                    loc="upper left",\
                                    borderaxespad=0.,\
                                    bbox_transform =\
                                        sD[scans[0]]["ue"]["ax"].transAxes,\
                                    )

    if direction == "radial":
        fileName = "BScanRad.pdf"
    elif direction == "parallel":
        fileName = "BScanPar.pdf"

    PlotHelper.savePlot(fig, fileName)
Exemple #18
0
jPar[ny]["leg"] = factorStr.format(ny * factor)
plt.close(fig)

fig, ax = plt.subplots(figsize=SizeMaker.standard(w=4, a=0.5))

colors = seqCMap2(np.linspace(0, 1, len(nys)))

for ny, color in zip(nys, colors):
    ax.plot(jPar[ny]["data"][0], jPar[ny]["data"][1],\
            label = jPar[ny]["leg"], alpha =0.7,\
            color = color
            )

ax.set_xlabel(r"$z\;[\mathrm{m}]$")
ax.set_ylabel(r"$j_\| \;[\mathrm{Cm}^{-2}\mathrm{s}^{-1}]$")
PlotHelper.makePlotPretty(ax)

# Move legend outside
handles, labels = ax.get_legend_handles_labels()
leg = ax.legend()
leg.remove()
fig.legend(handles,\
           labels ,\
           bbox_to_anchor=(1.05, 1.0),\
           loc="upper left",\
           borderaxespad=0.,\
           bbox_transform = ax.transAxes,\
           )

PlotHelper.savePlot(fig, "jParRipple006.pdf")